Skip to content

Commit 04d520e

Browse files
committed
MAGETWO-91798: Implement GroupedProduct Price indexer
1 parent f1fe1fe commit 04d520e

File tree

1 file changed

+3
-131
lines changed
  • app/code/Magento/GroupedProduct/Model/ResourceModel/Product/Indexer/Price

1 file changed

+3
-131
lines changed

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

Lines changed: 3 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Magento\Eav\Model\Config;
1212
use Magento\Framework\App\ResourceConnection;
1313
use Magento\Framework\DB\Adapter\AdapterInterface;
14-
use Magento\Framework\Event\ManagerInterface;
1514
use Magento\Framework\Indexer\DimensionalIndexerInterface;
1615
use Magento\Framework\EntityManager\MetadataPool;
1716
use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer;
@@ -31,11 +30,6 @@
3130
*/
3231
class Grouped implements DimensionalIndexerInterface
3332
{
34-
/**
35-
* Prefix for temporary table support.
36-
*/
37-
const TRANSIT_PREFIX = 'transit_';
38-
3933
/**
4034
* @var BaseFinalPrice
4135
*/
@@ -154,32 +148,10 @@ public function executeByDimension(array $dimensions, \Traversable $entityIds =
154148
'maxPriceField' => 'max_price',
155149
'tierPriceField' => 'tier_price',
156150
]);
157-
$this->fillFinalPrice($dimensions, $entityIds, $temporaryPriceTable);
158-
$this->applyPriceModifiers($temporaryPriceTable);
159151

160-
// if (!$this->tableStrategy->getUseIdxTable()) {
161-
// $additionalIdxTable = $this->cteateTempTable($temporaryPriceTable);
162-
// $this->fillTemporaryTable($entityIds, $additionalIdxTable);
163-
// $this->updateIdxTable($additionalIdxTable, $temporaryPriceTable->getTableName());
164-
// $this->connection->dropTemporaryTable($additionalIdxTable);
165-
// } else {
166-
$query = $this->_prepareGroupedProductPriceDataSelect($dimensions, iterator_to_array($entityIds))
167-
->insertFromSelect($temporaryPriceTable->getTableName());
168-
$this->connection->query($query);
169-
// }
170-
}
171-
172-
/**
173-
* Apply price modifiers to temporary price index table
174-
*
175-
* @param IndexTableStructure $temporaryPriceTable
176-
* @return void
177-
*/
178-
private function applyPriceModifiers(IndexTableStructure $temporaryPriceTable)
179-
{
180-
foreach ($this->priceModifiers as $priceModifier) {
181-
$priceModifier->modifyPrice($temporaryPriceTable);
182-
}
152+
$query = $this->_prepareGroupedProductPriceDataSelect($dimensions, iterator_to_array($entityIds))
153+
->insertFromSelect($temporaryPriceTable->getTableName());
154+
$this->connection->query($query);
183155
}
184156

185157
/**
@@ -254,108 +226,8 @@ protected function _prepareGroupedProductPriceDataSelect($dimensions, $entityIds
254226
return $select;
255227
}
256228

257-
/**
258-
* Add website data join to select
259-
* If add default store join also limitation of only has default store website
260-
* Joined table has aliases
261-
* cw for website table,
262-
* csg for store group table (joined by website default group)
263-
* cs for store table (joined by website default store)
264-
*
265-
* @param \Magento\Framework\DB\Select $select the select object
266-
* @param bool $store add default store join
267-
* @param string|\Zend_Db_Expr $joinCondition the limitation for website_id
268-
* @return $this
269-
*/
270-
protected function _addWebsiteJoinToSelect($select, $store = true, $joinCondition = null)
271-
{
272-
if ($joinCondition !== null) {
273-
$joinCondition = 'cw.website_id = ' . $joinCondition;
274-
}
275-
276-
$select->join(['cw' => $this->getTable('store_website')], $joinCondition, []);
277-
278-
if ($store) {
279-
$select->join(
280-
['csg' => $this->getTable('store_group')],
281-
'csg.group_id = cw.default_group_id',
282-
[]
283-
)->join(
284-
['cs' => $this->getTable('store')],
285-
'cs.store_id = csg.default_store_id',
286-
[]
287-
);
288-
}
289-
290-
return $this;
291-
}
292-
293229
private function getTable($tableName)
294230
{
295231
return $this->resource->getTableName($tableName, $this->connectionName);
296232
}
297-
298-
/**
299-
* @param array $dimensions
300-
* @param \Traversable $entityIds
301-
* @param $temporaryPriceTable
302-
*/
303-
private function fillFinalPrice(array $dimensions, \Traversable $entityIds, $temporaryPriceTable): void
304-
{
305-
$select = $this->baseFinalPrice->getQuery(
306-
$dimensions,
307-
GroupedType::TYPE_CODE,
308-
iterator_to_array($entityIds)
309-
);
310-
$query = $select->insertFromSelect($temporaryPriceTable->getTableName(), [], false);
311-
$this->tableMaintainer->getConnection()->query($query);
312-
}
313-
314-
/**
315-
* @param $table
316-
* @return mixed
317-
*/
318-
private function cteateTempTable($table)
319-
{
320-
321-
$temporaryOptionsTableName = 'catalog_product_index_price_cfg_opt_temp';
322-
$this->connection->createTemporaryTableLike(
323-
$temporaryOptionsTableName,
324-
$this->getTable('catalog_product_index_price_cfg_opt_tmp'),
325-
true
326-
);
327-
$additionalIdxTable = $this->connection->getTableName(self::TRANSIT_PREFIX . $this->getIdxTable());
328-
$this->connection->createTemporaryTableLike($additionalIdxTable, $table);
329-
return $additionalIdxTable;
330-
}
331-
332-
/**
333-
* @param $entityIds
334-
* @param $additionalIdxTable
335-
*/
336-
private function fillTemporaryTable($entityIds, $additionalIdxTable)
337-
{
338-
$query = $this->connection->insertFromSelect(
339-
$this->_prepareGroupedProductPriceDataSelect($entityIds),
340-
$additionalIdxTable,
341-
[]
342-
);
343-
$this->connection->query($query);
344-
}
345-
346-
/**
347-
* @param $additionalIdxTable
348-
* @param $table
349-
*/
350-
private function updateIdxTable($additionalIdxTable, $table): void
351-
{
352-
$select = $this->connection->select()->from($additionalIdxTable);
353-
$query = $this->connection->insertFromSelect(
354-
$select,
355-
$table,
356-
[],
357-
AdapterInterface::INSERT_ON_DUPLICATE
358-
);
359-
$this->connection->query($query);
360-
}
361233
}

0 commit comments

Comments
 (0)