Skip to content

Commit 79c6bbc

Browse files
committed
MAGETWO-92447: [Indexer optimizations] Tables sharding / segmentation for price indexer - part 3
1 parent 7a0f8e9 commit 79c6bbc

File tree

8 files changed

+20
-50
lines changed

8 files changed

+20
-50
lines changed

app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Framework\Indexer\DimensionalIndexerInterface;
1111
use Magento\Framework\EntityManager\MetadataPool;
1212
use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer;
13-
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\BaseFinalPrice;
1413
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableStructureFactory;
1514
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableStructure;
1615
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\JoinAttributeProcessor;
@@ -21,18 +20,10 @@
2120
/**
2221
* Bundle products Price indexer resource model
2322
*
24-
* @author Magento Core Team <core@magentocommerce.com>
25-
*
26-
* @SuppressWarnings(PHPMD.TooManyFields)
2723
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2824
*/
2925
class Price implements DimensionalIndexerInterface
3026
{
31-
/**
32-
* @var BaseFinalPrice
33-
*/
34-
private $baseFinalPrice;
35-
3627
/**
3728
* @var IndexTableStructureFactory
3829
*/
@@ -88,30 +79,23 @@ class Price implements DimensionalIndexerInterface
8879
*/
8980
private $joinAttributeProcessor;
9081

91-
/**
92-
* @var \Magento\Eav\Model\Config
93-
*/
94-
private $eavConfig;
95-
9682
/**
9783
* @var \Magento\Framework\Event\ManagerInterface
9884
*/
99-
private $eventManager = null;
85+
private $eventManager;
10086

10187
/**
10288
* @var \Magento\Framework\Module\Manager
10389
*/
10490
private $moduleManager;
10591

10692
/**
107-
* @param BaseFinalPrice $baseFinalPrice
10893
* @param IndexTableStructureFactory $indexTableStructureFactory
10994
* @param TableMaintainer $tableMaintainer
11095
* @param MetadataPool $metadataPool
11196
* @param \Magento\Framework\App\ResourceConnection $resource
11297
* @param BasePriceModifier $basePriceModifier
11398
* @param JoinAttributeProcessor $joinAttributeProcessor
114-
* @param \Magento\Eav\Model\Config $eavConfig
11599
* @param \Magento\Framework\Event\ManagerInterface $eventManager
116100
* @param \Magento\Framework\Module\Manager $moduleManager
117101
* @param bool $fullReindexAction
@@ -120,20 +104,17 @@ class Price implements DimensionalIndexerInterface
120104
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
121105
*/
122106
public function __construct(
123-
BaseFinalPrice $baseFinalPrice,
124107
IndexTableStructureFactory $indexTableStructureFactory,
125108
TableMaintainer $tableMaintainer,
126109
MetadataPool $metadataPool,
127110
\Magento\Framework\App\ResourceConnection $resource,
128111
BasePriceModifier $basePriceModifier,
129112
JoinAttributeProcessor $joinAttributeProcessor,
130-
\Magento\Eav\Model\Config $eavConfig,
131113
\Magento\Framework\Event\ManagerInterface $eventManager,
132114
\Magento\Framework\Module\Manager $moduleManager,
133115
$fullReindexAction = false,
134116
$connectionName = 'indexer'
135117
) {
136-
$this->baseFinalPrice = $baseFinalPrice;
137118
$this->indexTableStructureFactory = $indexTableStructureFactory;
138119
$this->tableMaintainer = $tableMaintainer;
139120
$this->connectionName = $connectionName;
@@ -142,7 +123,6 @@ public function __construct(
142123
$this->fullReindexAction = $fullReindexAction;
143124
$this->basePriceModifier = $basePriceModifier;
144125
$this->joinAttributeProcessor = $joinAttributeProcessor;
145-
$this->eavConfig = $eavConfig;
146126
$this->eventManager = $eventManager;
147127
$this->moduleManager = $moduleManager;
148128
}
@@ -152,7 +132,7 @@ public function __construct(
152132
*
153133
* @throws \Exception
154134
*/
155-
public function executeByDimension(array $dimensions, \Traversable $entityIds = null)
135+
public function executeByDimensions(array $dimensions, \Traversable $entityIds)
156136
{
157137
$this->tableMaintainer->createMainTmpTable($dimensions);
158138

@@ -261,15 +241,13 @@ private function prepareBundleOptionTable()
261241
* @param array $dimensions
262242
* @param int $priceType
263243
* @param int|array $entityIds the entity ids limitation
264-
* @return $this
244+
* @return void
265245
* @throws \Exception
266246
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
267247
*/
268248
private function prepareBundlePriceByType($priceType, array $dimensions, $entityIds = null)
269249
{
270250
$connection = $this->getConnection();
271-
$table = $this->getBundlePriceTable();
272-
273251
$select = $connection->select()->from(
274252
['e' => $this->getTable('catalog_product_entity')],
275253
['entity_id']
@@ -393,10 +371,8 @@ private function prepareBundlePriceByType($priceType, array $dimensions, $entity
393371
]
394372
);
395373

396-
$query = $select->insertFromSelect($table);
374+
$query = $select->insertFromSelect($this->getBundlePriceTable());
397375
$connection->query($query);
398-
399-
return $this;
400376
}
401377

402378
/**
@@ -405,7 +381,7 @@ private function prepareBundlePriceByType($priceType, array $dimensions, $entity
405381
* @param IndexTableStructure $priceTable
406382
* @param array $dimensions
407383
*
408-
* @return $this
384+
* @return void
409385
* @throws \Exception
410386
*/
411387
private function calculateBundleOptionPrice($priceTable, $dimensions)
@@ -442,16 +418,14 @@ private function calculateBundleOptionPrice($priceTable, $dimensions)
442418
$this->getConnection()->delete($priceTable->getTableName());
443419
$this->applyBundlePrice($priceTable);
444420
$this->applyBundleOptionPrice($priceTable);
445-
446-
return $this;
447421
}
448422

449423
/**
450424
* Calculate bundle product selections price by product type
451425
*
452426
* @param array $dimensions
453427
* @param int $priceType
454-
* @return $this
428+
* @return void
455429
* @throws \Exception
456430
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
457431
*/
@@ -562,19 +536,17 @@ private function calculateBundleSelectionPrice($dimensions, $priceType)
562536

563537
$query = $select->insertFromSelect($this->getBundleSelectionTable());
564538
$connection->query($query);
565-
566-
return $this;
567539
}
568540

569541
/**
570542
* Prepare percentage tier price for bundle products
571543
*
572544
* @param array $dimensions
573-
* @param int|array $entityIds
574-
* @return $this
545+
* @param array $entityIds
546+
* @return void
575547
* @throws \Exception
576548
*/
577-
private function prepareTierPriceIndex($dimensions, $entityIds = null)
549+
private function prepareTierPriceIndex($dimensions, $entityIds)
578550
{
579551
$connection = $this->getConnection();
580552
$metadata = $this->metadataPool->getMetadata(ProductInterface::class);
@@ -634,8 +606,6 @@ private function prepareTierPriceIndex($dimensions, $entityIds = null)
634606

635607
$query = $select->insertFromSelect($this->getTable('catalog_product_index_tier_price'));
636608
$connection->query($query);
637-
638-
return $this;
639609
}
640610

641611
/**

app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ protected function _reindexRows($changedIds = [])
381381
$this->tableMaintainer->createMainTmpTable($dimensions);
382382
$temporaryTable = $this->tableMaintainer->getMainTmpTable($dimensions);
383383
$this->_emptyTable($temporaryTable);
384-
$indexer->executeByDimension($dimensions, \SplFixedArray::fromArray($entityIds, false));
384+
$indexer->executeByDimensions($dimensions, \SplFixedArray::fromArray($entityIds, false));
385385
// copy to index
386386
$this->_insertFromTable(
387387
$temporaryTable,

app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ private function reindexByBatchWithDimensions(
276276
$temporaryTable = $this->dimensionTableMaintainer->getMainTmpTable($dimensions);
277277
$this->_emptyTable($temporaryTable);
278278

279-
$priceIndexer->executeByDimension($dimensions, \SplFixedArray::fromArray($entityIds, false));
279+
$priceIndexer->executeByDimensions($dimensions, \SplFixedArray::fromArray($entityIds, false));
280280

281281
// Sync data from temp table to index table
282282
$this->_insertFromTable(

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __construct(
6464
/**
6565
* {@inheritdoc}
6666
*/
67-
public function executeByDimension(array $dimensions, \Traversable $entityIds = null)
67+
public function executeByDimensions(array $dimensions, \Traversable $entityIds)
6868
{
6969
$this->tableMaintainer->createMainTmpTable($dimensions);
7070

app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function __construct(
100100
*
101101
* @throws \Exception
102102
*/
103-
public function executeByDimension(array $dimensions, \Traversable $entityIds = null)
103+
public function executeByDimensions(array $dimensions, \Traversable $entityIds)
104104
{
105105
$this->tableMaintainer->createMainTmpTable($dimensions);
106106

app/code/Magento/Downloadable/Model/ResourceModel/Indexer/Price.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function __construct(
104104
*
105105
* @throws \Exception
106106
*/
107-
public function executeByDimension(array $dimensions, \Traversable $entityIds = null)
107+
public function executeByDimensions(array $dimensions, \Traversable $entityIds)
108108
{
109109
$temporaryPriceTable = $this->indexTableStructureFactory->create([
110110
'tableName' => $this->tableMaintainer->getMainTmpTable($dimensions),

app/code/Magento/GroupedProduct/Model/ResourceModel/Product/Indexer/Price/Grouped.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function __construct(
8989
*
9090
* @throws \Exception
9191
*/
92-
public function executeByDimension(array $dimensions, \Traversable $entityIds = null)
92+
public function executeByDimensions(array $dimensions, \Traversable $entityIds)
9393
{
9494
/** @var IndexTableStructure $temporaryPriceTable */
9595
$temporaryPriceTable = $this->indexTableStructureFactory->create([
@@ -112,12 +112,12 @@ public function executeByDimension(array $dimensions, \Traversable $entityIds =
112112
/**
113113
* Prepare data index select for Grouped products prices
114114
*
115-
* @param $dimensions
116-
* @param int|array $entityIds the parent entity ids limitation
115+
* @param array $dimensions
116+
* @param array $entityIds the parent entity ids limitation
117117
* @return \Magento\Framework\DB\Select
118118
* @throws \Exception
119119
*/
120-
protected function prepareGroupedProductPriceDataSelect($dimensions, $entityIds = null)
120+
private function prepareGroupedProductPriceDataSelect(array $dimensions, array $entityIds)
121121
{
122122
$select = $this->getConnection()->select();
123123

lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ interface DimensionalIndexerInterface
1717
* Accept array of dimensions DTO that represent indexer dimension
1818
*
1919
* @param \Magento\Framework\Indexer\Dimension[] $dimensions
20-
* @param \Traversable|null $entityIds
20+
* @param \Traversable $entityIds
2121
* @return void
2222
*/
23-
public function executeByDimension(array $dimensions, \Traversable $entityIds = null);
23+
public function executeByDimensions(array $dimensions, \Traversable $entityIds);
2424
}

0 commit comments

Comments
 (0)