9
9
use Magento \Catalog \Model \Product ;
10
10
use Magento \Catalog \Model \ProductFactory ;
11
11
use Magento \Catalog \Model \ResourceModel \Indexer \ActiveTableSwitcher ;
12
+ use Magento \Catalog \Model \Indexer \Product \Price \Processor as PriceIndexProcessor ;
13
+ use Magento \CatalogRule \Model \Indexer \Rule \RuleProductProcessor ;
12
14
use Magento \CatalogRule \Model \Indexer \IndexBuilder \ProductLoader ;
13
15
use Magento \CatalogRule \Model \Indexer \IndexerTableSwapperInterface as TableSwapper ;
14
16
use Magento \CatalogRule \Model \ResourceModel \Rule \Collection as RuleCollection ;
18
20
use Magento \Framework \App \ObjectManager ;
19
21
use Magento \Framework \App \ResourceConnection ;
20
22
use Magento \Framework \Exception \LocalizedException ;
23
+ use Magento \Framework \Indexer \IndexerRegistry ;
21
24
use Magento \Framework \Pricing \PriceCurrencyInterface ;
22
25
use Magento \Framework \Stdlib \DateTime ;
23
26
use Magento \Framework \Stdlib \DateTime \TimezoneInterface ;
@@ -167,6 +170,11 @@ class IndexBuilder
167
170
*/
168
171
private $ productLoader ;
169
172
173
+ /**
174
+ * @var IndexerRegistry
175
+ */
176
+ private $ indexerRegistry ;
177
+
170
178
/**
171
179
* @param RuleCollectionFactory $ruleCollectionFactory
172
180
* @param PriceCurrencyInterface $priceCurrency
@@ -188,6 +196,7 @@ class IndexBuilder
188
196
* @param ProductLoader|null $productLoader
189
197
* @param TableSwapper|null $tableSwapper
190
198
* @param TimezoneInterface|null $localeDate
199
+ * @param IndexerRegistry|null $indexerRegistry
191
200
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
192
201
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
193
202
*/
@@ -211,7 +220,8 @@ public function __construct(
211
220
ActiveTableSwitcher $ activeTableSwitcher = null ,
212
221
ProductLoader $ productLoader = null ,
213
222
TableSwapper $ tableSwapper = null ,
214
- TimezoneInterface $ localeDate = null
223
+ TimezoneInterface $ localeDate = null ,
224
+ IndexerRegistry $ indexerRegistry = null
215
225
) {
216
226
$ this ->resource = $ resource ;
217
227
$ this ->connection = $ resource ->getConnection ();
@@ -253,6 +263,8 @@ public function __construct(
253
263
ObjectManager::getInstance ()->get (TableSwapper::class);
254
264
$ this ->localeDate = $ localeDate ??
255
265
ObjectManager::getInstance ()->get (TimezoneInterface::class);
266
+ $ this ->indexerRegistry = $ indexerRegistry ??
267
+ ObjectManager::getInstance ()->get (IndexerRegistry::class);
256
268
}
257
269
258
270
/**
@@ -323,6 +335,15 @@ protected function doReindexByIds($ids)
323
335
$ this ->reindexRuleProductPrice ->execute ($ this ->batchCount , $ productId );
324
336
}
325
337
338
+ //the case was not handled via indexer dependency decorator or via mview configuration
339
+ $ ruleIndexer = $ this ->indexerRegistry ->get (RuleProductProcessor::INDEXER_ID );
340
+ if ($ ruleIndexer ->isScheduled ()) {
341
+ $ priceIndexer = $ this ->indexerRegistry ->get (PriceIndexProcessor::INDEXER_ID );
342
+ if (!$ priceIndexer ->isScheduled ()) {
343
+ $ priceIndexer ->reindexList ($ ids );
344
+ }
345
+ }
346
+
326
347
$ this ->reindexRuleGroupWebsite ->execute ();
327
348
}
328
349
0 commit comments