88namespace Magento \ConfigurableProduct \Model \ResourceModel \Product \Indexer \Price ;
99
1010use Magento \Catalog \Api \Data \ProductInterface ;
11- use Magento \Catalog \Model \Product \Attribute \Source \Status as ProductStatus ;
12- use Magento \Catalog \Model \Product \Attribute \Source \Status ;
1311use Magento \Store \Api \StoreResolverInterface ;
14- use Magento \Store \Model \Store ;
1512
1613/**
1714 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -58,7 +55,7 @@ protected function reindex($entityIds = null)
5855 if ($ this ->hasEntity () || !empty ($ entityIds )) {
5956 $ this ->prepareFinalPriceDataForType ($ entityIds , $ this ->getTypeId ());
6057 $ this ->_applyCustomOption ();
61- $ this ->_applyConfigurableOption ();
58+ $ this ->_applyConfigurableOption ($ entityIds );
6259 $ this ->_movePriceDataToIndexTable ($ entityIds );
6360 }
6461 return $ this ;
@@ -110,10 +107,11 @@ protected function _prepareConfigurableOptionPriceTable()
110107 * Calculate minimal and maximal prices for configurable product options
111108 * and apply it to final price
112109 *
110+ * @param array|null $entityIds
113111 * @return \Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price\Configurable
114112 * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
115113 */
116- protected function _applyConfigurableOption ()
114+ protected function _applyConfigurableOption ($ entityIds = null )
117115 {
118116 $ metadata = $ this ->getMetadataPool ()->getMetadata (ProductInterface::class);
119117 $ connection = $ this ->getConnection ();
@@ -133,12 +131,12 @@ protected function _applyConfigurableOption()
133131 ['le ' => $ this ->getTable ('catalog_product_entity ' )],
134132 'le. ' . $ linkField . ' = l.parent_id ' ,
135133 ['parent_id ' => 'entity_id ' ]
136- )->join (
137- ['i ' => $ this ->_getDefaultFinalPriceTable ()],
138- 'le.entity_id = i.entity_id ' ,
139- []
140134 );
141135
136+ if ($ entityIds !== null ) {
137+ $ subSelect ->where ('le.entity_id IN (?) ' , $ entityIds );
138+ }
139+
142140 $ select = $ connection ->select ();
143141 $ select
144142 ->from (['sub ' => new \Zend_Db_Expr ('( ' . (string )$ subSelect . ') ' )], '' )
@@ -178,6 +176,7 @@ protected function _applyConfigurableOption()
178176 ' AND i.website_id = io.website_id ' ,
179177 []
180178 );
179+ // adds price of custom option, that was applied in DefaultPrice::_applyCustomOption
181180 $ select ->columns (
182181 [
183182 'min_price ' => new \Zend_Db_Expr ('i.min_price - i.orig_price + io.min_price ' ),
0 commit comments