Target rule is throwing Undefined array key while indexing
Author: adarshkhatriCreated Aug 28, 2026Updated Sep 28, 2026
LabelsIssue: needs updateReported on 2.4.7 -p10
Preconditions and environment
- Magento version: 2.4.7-p10 Commerce
- Quality patch applied: https://experienceleague.adobe.com/en/docs/commerce-operations/tools/quality-patches-tool/patches-available-in-qpt/v1-1-78/acp2e-4431
- Indexers are set to "Run by Schedule"
Steps to reproduce
- Create 2 upsell/related rules:
Rule A: a. Matching product: category- Category A b. Displaying product: category- Category B
Rule B: a. Matching product: category- Category P b. Displaying product: category- Category Q
- Create 2 products:
- Product "My Product". Assign to
Category A. - Product "Your Product". Assign to
Category P.
- After all the indexer changelogs have finished, do a GQL query to get the related/upsell products for
My product. You should get the upsell/related products from "Category B". - Tail your server logs.
- Edit product
My productand change its category toCategory P. - Let the indexer changelog kick in.
- Observe the error in the logs.
You should see an error like this:
Cron Job indexer_update_all_views has an error: Warning: Undefined array key 171 in /vendor/magento/module-target-rule/Model/Indexer/TargetRule/AbstractAction.php on line 180. Statistics: {"sum":0,"count":1,"realmem":0,"emalloc":0,"realmem_start":140509184,"emalloc_start":65836080} [] []The culprit line is:
$entitiesToDelete[$ruleId] = $existingEntities[$ruleId];Expected result
- It should complete the indexer and should not throw an error.
- The upsell/related product request for
my productshould give you upsell/related products fromCategory Qonly. - The DB table should have only one row for this product for Rule B.
Actual result
- It throws an error.
- The upsell/related product request for
my productgives you results from bothCategory PandCategory Q.
Additional information
While indexing, it assigns the product to a new rule, but it fails to remove old entries from the DB table, which is why we have entries for both rules.
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Source: magento/magento2