@@ -58,7 +58,7 @@ protected function reindex($entityIds = null)
58
58
if ($ this ->hasEntity () || !empty ($ entityIds )) {
59
59
$ this ->prepareFinalPriceDataForType ($ entityIds , $ this ->getTypeId ());
60
60
$ this ->_applyCustomOption ();
61
- $ this ->_applyConfigurableOption ();
61
+ $ this ->_applyConfigurableOption ($ entityIds );
62
62
$ this ->_movePriceDataToIndexTable ($ entityIds );
63
63
}
64
64
return $ this ;
@@ -110,10 +110,11 @@ protected function _prepareConfigurableOptionPriceTable()
110
110
* Calculate minimal and maximal prices for configurable product options
111
111
* and apply it to final price
112
112
*
113
+ * @param null|int|array $entityIds
113
114
* @return \Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price\Configurable
114
115
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
115
116
*/
116
- protected function _applyConfigurableOption ()
117
+ protected function _applyConfigurableOption ($ entityIds = null )
117
118
{
118
119
$ metadata = $ this ->getMetadataPool ()->getMetadata (ProductInterface::class);
119
120
$ connection = $ this ->getConnection ();
@@ -133,12 +134,12 @@ protected function _applyConfigurableOption()
133
134
['le ' => $ this ->getTable ('catalog_product_entity ' )],
134
135
'le. ' . $ linkField . ' = l.parent_id ' ,
135
136
['parent_id ' => 'entity_id ' ]
136
- )->join (
137
- ['i ' => $ this ->_getDefaultFinalPriceTable ()],
138
- 'le.entity_id = i.entity_id ' ,
139
- []
140
137
);
141
138
139
+ if ($ entityIds !== null ) {
140
+ $ subSelect ->where ('le.entity_id IN (?) ' , $ entityIds );
141
+ }
142
+
142
143
$ select = $ connection ->select ();
143
144
$ select
144
145
->from (['sub ' => new \Zend_Db_Expr ('( ' . (string )$ subSelect . ') ' )], '' )
@@ -178,6 +179,7 @@ protected function _applyConfigurableOption()
178
179
' AND i.website_id = io.website_id ' ,
179
180
[]
180
181
);
182
+ // adds price of custom option, that was applied in DefaultPrice::_applyCustomOption
181
183
$ select ->columns (
182
184
[
183
185
'min_price ' => new \Zend_Db_Expr ('i.min_price - i.orig_price + io.min_price ' ),
0 commit comments