|
11 | 11 | use Magento\Eav\Model\Config;
|
12 | 12 | use Magento\Framework\App\ResourceConnection;
|
13 | 13 | use Magento\Framework\DB\Adapter\AdapterInterface;
|
14 |
| -use Magento\Framework\Event\ManagerInterface; |
15 | 14 | use Magento\Framework\Indexer\DimensionalIndexerInterface;
|
16 | 15 | use Magento\Framework\EntityManager\MetadataPool;
|
17 | 16 | use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer;
|
|
31 | 30 | */
|
32 | 31 | class Grouped implements DimensionalIndexerInterface
|
33 | 32 | {
|
34 |
| - /** |
35 |
| - * Prefix for temporary table support. |
36 |
| - */ |
37 |
| - const TRANSIT_PREFIX = 'transit_'; |
38 |
| - |
39 | 33 | /**
|
40 | 34 | * @var BaseFinalPrice
|
41 | 35 | */
|
@@ -154,32 +148,10 @@ public function executeByDimension(array $dimensions, \Traversable $entityIds =
|
154 | 148 | 'maxPriceField' => 'max_price',
|
155 | 149 | 'tierPriceField' => 'tier_price',
|
156 | 150 | ]);
|
157 |
| - $this->fillFinalPrice($dimensions, $entityIds, $temporaryPriceTable); |
158 |
| - $this->applyPriceModifiers($temporaryPriceTable); |
159 | 151 |
|
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); |
183 | 155 | }
|
184 | 156 |
|
185 | 157 | /**
|
@@ -254,108 +226,8 @@ protected function _prepareGroupedProductPriceDataSelect($dimensions, $entityIds
|
254 | 226 | return $select;
|
255 | 227 | }
|
256 | 228 |
|
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 |
| - |
293 | 229 | private function getTable($tableName)
|
294 | 230 | {
|
295 | 231 | return $this->resource->getTableName($tableName, $this->connectionName);
|
296 | 232 | }
|
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 |
| - } |
361 | 233 | }
|
0 commit comments