Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SimpleProductPrice.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
8 
12 
17 {
21  private $baseFinalPrice;
22 
26  private $indexTableStructureFactory;
27 
31  private $tableMaintainer;
32 
36  private $productType;
37 
41  private $basePriceModifier;
42 
50  public function __construct(
51  BaseFinalPrice $baseFinalPrice,
52  IndexTableStructureFactory $indexTableStructureFactory,
53  TableMaintainer $tableMaintainer,
54  BasePriceModifier $basePriceModifier,
55  $productType = \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
56  ) {
57  $this->baseFinalPrice = $baseFinalPrice;
58  $this->indexTableStructureFactory = $indexTableStructureFactory;
59  $this->tableMaintainer = $tableMaintainer;
60  $this->productType = $productType;
61  $this->basePriceModifier = $basePriceModifier;
62  }
63 
67  public function executeByDimensions(array $dimensions, \Traversable $entityIds)
68  {
69  $this->tableMaintainer->createMainTmpTable($dimensions);
70 
71  $temporaryPriceTable = $this->indexTableStructureFactory->create([
72  'tableName' => $this->tableMaintainer->getMainTmpTable($dimensions),
73  'entityField' => 'entity_id',
74  'customerGroupField' => 'customer_group_id',
75  'websiteField' => 'website_id',
76  'taxClassField' => 'tax_class_id',
77  'originalPriceField' => 'price',
78  'finalPriceField' => 'final_price',
79  'minPriceField' => 'min_price',
80  'maxPriceField' => 'max_price',
81  'tierPriceField' => 'tier_price',
82  ]);
83  $select = $this->baseFinalPrice->getQuery($dimensions, $this->productType, iterator_to_array($entityIds));
84  $query = $select->insertFromSelect($temporaryPriceTable->getTableName(), [], false);
85  $this->tableMaintainer->getConnection()->query($query);
86 
87  $this->basePriceModifier->modifyPrice($temporaryPriceTable, iterator_to_array($entityIds));
88  }
89 }
__construct(BaseFinalPrice $baseFinalPrice, IndexTableStructureFactory $indexTableStructureFactory, TableMaintainer $tableMaintainer, BasePriceModifier $basePriceModifier, $productType=\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)