diff --git a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php index a30ec81528dd38691e65bafd417aa59ae32ab3d7..40f390d5269749266c57901e991c80aaacaf295c 100644 --- a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php @@ -58,7 +58,7 @@ class Configurable extends \Magento\Catalog\Model\ResourceModel\Product\Indexer\ if ($this->hasEntity() || !empty($entityIds)) { $this->prepareFinalPriceDataForType($entityIds, $this->getTypeId()); $this->_applyCustomOption(); - $this->_applyConfigurableOption(); + $this->_applyConfigurableOption($entityIds); $this->_movePriceDataToIndexTable($entityIds); } return $this; @@ -110,10 +110,11 @@ class Configurable extends \Magento\Catalog\Model\ResourceModel\Product\Indexer\ * Calculate minimal and maximal prices for configurable product options * and apply it to final price * + * @param null|int|array $entityIds * @return \Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price\Configurable * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - protected function _applyConfigurableOption() + protected function _applyConfigurableOption($entityIds = null) { $metadata = $this->getMetadataPool()->getMetadata(ProductInterface::class); $connection = $this->getConnection(); @@ -133,12 +134,12 @@ class Configurable extends \Magento\Catalog\Model\ResourceModel\Product\Indexer\ ['le' => $this->getTable('catalog_product_entity')], 'le.' . $linkField . ' = l.parent_id', ['parent_id' => 'entity_id'] - )->join( - ['i' => $this->_getDefaultFinalPriceTable()], - 'le.entity_id = i.entity_id', - [] ); + if ($entityIds !== null) { + $subSelect->where('le.entity_id IN (?)', $entityIds); + } + $select = $connection->select(); $select ->from(['sub' => new \Zend_Db_Expr('(' . (string)$subSelect . ')')], '') @@ -178,6 +179,7 @@ class Configurable extends \Magento\Catalog\Model\ResourceModel\Product\Indexer\ ' AND i.website_id = io.website_id', [] ); + // adds price of custom option, that was applied in DefaultPrice::_applyCustomOption $select->columns( [ 'min_price' => new \Zend_Db_Expr('i.min_price - i.orig_price + io.min_price'),