Skip to content

Commit 1c96b6d

Browse files
committed
MC-19646: [Magento Cloud] - Catalog Product Rule Indexer stuck
1 parent b944f82 commit 1c96b6d

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -292,25 +292,30 @@ protected function doReindexByIds($ids)
292292

293293
/** @var Rule[] $activeRules */
294294
$activeRules = $this->getActiveRules()->getItems();
295-
foreach ($ids as $productId) {
296-
foreach ($activeRules as $activeRule) {
297-
$rule = clone $activeRule;
298-
$rule->setProductsFilter($ids);
299-
$matchedProductIds = $rule->getMatchingProductIds();
300-
$matchedProductIds = array_intersect_key($matchedProductIds, array_flip($ids));
301-
foreach ($matchedProductIds as $matchedProductId => $validationByWebsite) {
302-
$websiteIds = array_keys(array_filter($validationByWebsite));
303-
if (empty($websiteIds)) {
304-
continue;
305-
}
306-
307-
$this->assignProductToRule($rule, $matchedProductId, $websiteIds);
295+
foreach ($activeRules as $activeRule) {
296+
$rule = clone $activeRule;
297+
$rule->setProductsFilter($ids);
298+
$matchedProductIds = $rule->getMatchingProductIds();
299+
if (empty($matchedProductIds)) {
300+
continue;
301+
}
302+
303+
$matchedProductIds = array_intersect_key($matchedProductIds, array_flip($ids));
304+
foreach ($matchedProductIds as $matchedProductId => $validationByWebsite) {
305+
$websiteIds = array_keys(array_filter($validationByWebsite));
306+
if (empty($websiteIds)) {
307+
continue;
308308
}
309+
310+
$this->assignProductToRule($rule, $matchedProductId, $websiteIds);
309311
}
312+
}
310313

314+
foreach ($ids as $productId) {
311315
$this->cleanProductPriceIndex([$productId]);
312316
$this->reindexRuleProductPrice->execute($this->batchCount, $productId);
313317
}
318+
314319
$this->reindexRuleGroupWebsite->execute();
315320
}
316321

0 commit comments

Comments
 (0)