99use Magento \Catalog \Model \Product ;
1010use Magento \Catalog \Model \ProductFactory ;
1111use 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 ;
1214use Magento \CatalogRule \Model \Indexer \IndexBuilder \ProductLoader ;
1315use Magento \CatalogRule \Model \Indexer \IndexerTableSwapperInterface as TableSwapper ;
1416use Magento \CatalogRule \Model \ResourceModel \Rule \Collection as RuleCollection ;
1820use Magento \Framework \App \ObjectManager ;
1921use Magento \Framework \App \ResourceConnection ;
2022use Magento \Framework \Exception \LocalizedException ;
23+ use Magento \Framework \Indexer \IndexerRegistry ;
2124use Magento \Framework \Pricing \PriceCurrencyInterface ;
2225use Magento \Framework \Stdlib \DateTime ;
2326use Magento \Framework \Stdlib \DateTime \TimezoneInterface ;
@@ -167,6 +170,11 @@ class IndexBuilder
167170 */
168171 private $ productLoader ;
169172
173+ /**
174+ * @var IndexerRegistry
175+ */
176+ private $ indexerRegistry ;
177+
170178 /**
171179 * @param RuleCollectionFactory $ruleCollectionFactory
172180 * @param PriceCurrencyInterface $priceCurrency
@@ -188,6 +196,7 @@ class IndexBuilder
188196 * @param ProductLoader|null $productLoader
189197 * @param TableSwapper|null $tableSwapper
190198 * @param TimezoneInterface|null $localeDate
199+ * @param IndexerRegistry|null $indexerRegistry
191200 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
192201 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
193202 */
@@ -211,7 +220,8 @@ public function __construct(
211220 ActiveTableSwitcher $ activeTableSwitcher = null ,
212221 ProductLoader $ productLoader = null ,
213222 TableSwapper $ tableSwapper = null ,
214- TimezoneInterface $ localeDate = null
223+ TimezoneInterface $ localeDate = null ,
224+ IndexerRegistry $ indexerRegistry = null
215225 ) {
216226 $ this ->resource = $ resource ;
217227 $ this ->connection = $ resource ->getConnection ();
@@ -253,6 +263,8 @@ public function __construct(
253263 ObjectManager::getInstance ()->get (TableSwapper::class);
254264 $ this ->localeDate = $ localeDate ??
255265 ObjectManager::getInstance ()->get (TimezoneInterface::class);
266+ $ this ->indexerRegistry = $ indexerRegistry ??
267+ ObjectManager::getInstance ()->get (IndexerRegistry::class);
256268 }
257269
258270 /**
@@ -323,6 +335,15 @@ protected function doReindexByIds($ids)
323335 $ this ->reindexRuleProductPrice ->execute ($ this ->batchCount , $ productId );
324336 }
325337
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+
326347 $ this ->reindexRuleGroupWebsite ->execute ();
327348 }
328349
0 commit comments