@@ -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