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