Skip to content

Commit 5d572a0

Browse files
authored
Merge pull request #1880 from magento-performance/MAGETWO-82888
Fixed issue: - MAGETWO-82888: [Performance] Product Price indexer stuck during reindexing
2 parents 89cf3a9 + f7e7b31 commit 5d572a0

File tree

1 file changed

+8
-6
lines changed
  • app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function reindex($entityIds = null)
5858
if ($this->hasEntity() || !empty($entityIds)) {
5959
$this->prepareFinalPriceDataForType($entityIds, $this->getTypeId());
6060
$this->_applyCustomOption();
61-
$this->_applyConfigurableOption();
61+
$this->_applyConfigurableOption($entityIds);
6262
$this->_movePriceDataToIndexTable($entityIds);
6363
}
6464
return $this;
@@ -110,10 +110,11 @@ protected function _prepareConfigurableOptionPriceTable()
110110
* Calculate minimal and maximal prices for configurable product options
111111
* and apply it to final price
112112
*
113+
* @param null|int|array $entityIds
113114
* @return \Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price\Configurable
114115
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
115116
*/
116-
protected function _applyConfigurableOption()
117+
protected function _applyConfigurableOption($entityIds = null)
117118
{
118119
$metadata = $this->getMetadataPool()->getMetadata(ProductInterface::class);
119120
$connection = $this->getConnection();
@@ -133,12 +134,12 @@ protected function _applyConfigurableOption()
133134
['le' => $this->getTable('catalog_product_entity')],
134135
'le.' . $linkField . ' = l.parent_id',
135136
['parent_id' => 'entity_id']
136-
)->join(
137-
['i' => $this->_getDefaultFinalPriceTable()],
138-
'le.entity_id = i.entity_id',
139-
[]
140137
);
141138

139+
if ($entityIds !== null) {
140+
$subSelect->where('le.entity_id IN (?)', $entityIds);
141+
}
142+
142143
$select = $connection->select();
143144
$select
144145
->from(['sub' => new \Zend_Db_Expr('(' . (string)$subSelect . ')')], '')
@@ -178,6 +179,7 @@ protected function _applyConfigurableOption()
178179
' AND i.website_id = io.website_id',
179180
[]
180181
);
182+
// adds price of custom option, that was applied in DefaultPrice::_applyCustomOption
181183
$select->columns(
182184
[
183185
'min_price' => new \Zend_Db_Expr('i.min_price - i.orig_price + io.min_price'),

0 commit comments

Comments
 (0)