#41081·magento2

Catalog rule price permanently lost for configurable products after a stock update via REST

Author: Conrado2011Created Aug 3, 2026Updated Sep 28, 2026
LabelsIssue: needs updateReported on 2.4.9

Preconditions and environment

  • Magento 2.4.9 (magento/product-community-edition 2.4.9). Also affects 2.4.8. Does not affect 2.4.7 — see Regression below.
  • magento/module-inventory-catalog-rule 100.2.1
  • magento/module-catalog-rule-configurable 100.4.8
  • MSI (Multi Source Inventory) enabled.
  • An active catalog price rule whose condition is evaluated on the parent product — e.g. category_ids is <id>. The essential property is that the condition cannot be satisfied by a child/simple product on its own.
  • Configurable products assigned to that category. Their children (simples) are not assigned to any category — the standard Magento setup, since categorization happens on the parent.
  • Catalog rule indexer set to Update by Schedule. (Irrelevant to the bug: the code path below forces a reindex regardless of the indexer mode.)

Steps to reproduce

  1. Verify the configurable shows the rule discount on the storefront, and that catalogrule_product contains rows for the child product IDs:

    sql
    SELECT * FROM catalogrule_product WHERE product_id IN (<child_id>);
  2. Push a stock change for one child SKU through the REST API, so that its saleability changes (e.g. quantity 0 → quantity > 0):

    POST /rest/V1/inventory/source-items
    json
    { "sourceItems": [ { "sku": "<child_sku>", "source_code": "default", "quantity": 10, "status": 1 } ] }

    The async bulk variant reproduces it as well:

    POST /rest/async/bulk/V1/inventory/source-items
  3. Query catalogrule_product again for the same product IDs.

Expected result

Rows in catalogrule_product for the affected product IDs are preserved (or deleted and correctly reinserted), and the configurable keeps its catalog rule price on the storefront.

Actual result

The rows are deleted and never reinserted. The configurable permanently loses its catalog rule price — the storefront renders the regular price with no discount — until a full reindex of catalogrule_rule runs in the crontab area (e.g. the nightly catalogrule_apply_all), which repopulates it.

Because the loss is silent and only affects the products whose stock happened to be pushed, the symptom looks random: a handful of SKUs lose their promotional price each day while the rest of the catalog is fine.

Root cause

Magento_InventoryCatalogRule registers a saleability processor:

xml
<!-- vendor/magento/module-inventory-catalog-rule/etc/di.xml -->
<type name="Magento\InventoryIndexer\Indexer\Stock\SkuListsProcessor">
    <arguments>
        <argument name="saleabilityChangesProcessorsPool" xsi:type="array">
            <item name="ruleIndexUpdateProcessor" xsi:type="object">Magento\InventoryCatalogRule\Model\RuleIndexUpdateProcessor</item>
        </argument>
    </arguments>
</type>

On any saleability change, RuleIndexUpdateProcessor calls reindexList($ids, true) — forceReindex = true, so it runs synchronously inside the request, ignoring Update by Schedule.

That reaches Magento\CatalogRule\Model\Indexer\IndexBuilder::doReindexByIds(), which deletes the rows first and reinserts only for products the rule validates.

Meanwhile, the three plugins that teach catalog rules about configurable products are registered only in adminhtml and crontab:

xml
<!-- vendor/magento/module-catalog-rule-configurable/etc/adminhtml/di.xml
     and etc/crontab/di.xml — identical files -->
<type name="Magento\CatalogRule\Model\Rule">
    <plugin name="addVariationsToProductRule" type="Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\Rule\ConfigurableProductHandler"/>
    <plugin name="configurableChildValidation"  type="Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\Rule\Validation"/>
</type>
<type name="Magento\CatalogRule\Model\Indexer\Product\ProductRuleIndexer">
    <plugin name="productRuleReindex" type="Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\Indexer\ProductRuleReindex"/>
</type>

The module's root etc/di.xml contains only catalogRulePriceForConfigurableProduct (AddCatalogRulePrice, on the collection) — none of the three above.

A REST stock push runs in the webapi_rest area; the async bulk consumer (async.operations.all) runs in global. Neither has these plugins. So Rule::getMatchingProductIds() evaluates the rule conditions against the child product alone, and the child has no categories of its own — the rule does not validate, zero rows are inserted, and the row deleted a moment earlier is gone for good.

Verifiable without a debugger:

bin/magento dev:di:info 'Magento\CatalogRule\Model\Rule' webapi_rest   # plugins absent
bin/magento dev:di:info 'Magento\CatalogRule\Model\Rule' adminhtml     # plugins present
bin/magento dev:di:info 'Magento\CatalogRule\Model\Indexer\Product\ProductRuleIndexer' webapi_rest   # no productRuleReindex

Regression

Magento_InventoryCatalogRule did not exist in 2.4.7: InventoryCatalogRule/etc/di.xml returns 404 in magento/inventory tag 1.2.7 and in all ten of its patch levels (1.2.7-p1 … 1.2.7-p10). It was never backported. It first appears in 1.2.8 (= 2.4.8), commit 76db21998bc0 (2024-04-04), ticket ACP2E-2805, "Catalog Promotions Rule not working with quantity_and_stock_status attribute".

The plugin scoping is not the change: CatalogRuleConfigurable/etc/di.xml and etc/adminhtml/di.xml are byte-identical across 2.4.7, 2.4.8 and 2.4.9 (only the copyright header differs). The narrow scoping is the pre-existing necessary condition; the new module is the trigger.

The irony worth noting: the module was added so catalog rules would react to stock changes. In doing so it broke configurables, because the reindex it triggers runs in an area where the configurable-awareness plugins are not wired.

The extension point already existed in 2.4.7 (saleabilityChangesProcessorsPool, processProductsWithChangedSaleability(), CompositeProductProcessorInterface). What did not exist was a catalog-rule processor plugged into it.

Aggravating factor in 2.4.9

IndexBuilder::cleanProductIndex() changed from a plain delete() (still the case in 2.4.8) to deleteRatio > 0.25 ? copyAndSwapTable() : batchRowsDelete() (ACP2E-4085, motivated by Galera writeset limits).

deleteRatio($tableName, $productIds) is rows to delete over total rows in the table — COUNT(*) WHERE product_id IN (...) divided by (SELECT COUNT(*) FROM catalogrule_product) — so the strategy depends on the size of the table, not on the size of the batch. With a catalogrule_product of tens of thousands of rows, deleting the rows of a single product yields a ratio near zero and takes batchRowsDelete(). The copy-and-swap path is only reached when one call deletes more than 25% of the table, i.e. a bulk stock sync.

Inside that window the aggravation is real, and worse than a slow query: copyAndSwapTable() fills the temporary table with INSERT .. SELECT .. WHERE product_id NOT IN (...) — a snapshot — and only then does the RENAME. Any row inserted concurrently between the SELECT and the RENAME lands in the table that is about to be renamed away as a backup, and is silently lost when that backup is dropped. This can affect products that were not part of the batch at all. The RENAME also causes an implicit commit, so it cannot be contained in the caller's transaction.

Suggested fix

Either of:

  1. Register the three Magento_CatalogRuleConfigurable plugins globally (etc/di.xml) instead of only adminhtml + crontab. Any code path that reindexes catalog rules needs configurable awareness, not just the admin and the cron.
  2. Make IndexBuilder::doReindexByIds() non-destructive: do not delete rows before knowing whether the rule will validate and reinsert.

Workaround

Primary workaround — register the three plugins globally from your own module. This is Suggested fix #1 applied downstream: it addresses the root cause instead of switching off the trigger, so the partial reindex keeps running but now resolves configurables correctly in every area.

xml
<!-- app/code/Vendor/Module/etc/di.xml — global, NOT etc/webapi_rest/di.xml -->
<type name="Magento\CatalogRule\Model\Rule">
    <plugin name="addVariationsToProductRule" type="Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\Rule\ConfigurableProductHandler"/>
    <plugin name="configurableChildValidation" type="Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\Rule\Validation"/>
</type>
<type name="Magento\CatalogRule\Model\Indexer\Product\ProductRuleIndexer">
    <plugin name="productRuleReindex" type="Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\Indexer\ProductRuleReindex"/>
</type>

Two details that are easy to get wrong:

  • The <plugin name="..."> values must be the vendor's own names. DI merges <plugin> nodes by their name attribute, so reusing the vendor's names makes the declaration merge into a single interceptor. With custom names a second interceptor is registered instead, and in adminhtml and crontab — where the vendor already declares these plugins — they would run twice.
  • It has to be the global etc/di.xml, not etc/webapi_rest/di.xml: the async bulk consumer runs in global, so an area-scoped override silently misses half of the traffic.

Alternative — replace the pool entry with a no-op processor, in a custom module's global etc/di.xml. This removes the trigger altogether and restores 2.4.7 behaviour:

xml
<type name="Magento\InventoryIndexer\Indexer\Stock\SkuListsProcessor">
    <arguments>
        <argument name="saleabilityChangesProcessorsPool" xsi:type="array">
            <item name="ruleIndexUpdateProcessor" xsi:type="object">Vendor\Module\Model\DisabledRuleIndexUpdateProcessor</item>
        </argument>
    </arguments>
</type>
php
class DisabledRuleIndexUpdateProcessor implements \Magento\InventoryIndexer\Indexer\SourceItem\CompositeProductProcessorInterface
{
    public function getSortOrder(): int
    {
        return 8; // same default as the vendor processor
    }

    public function process(array $saleableStatusesBeforeSync, array $saleableStatusesAfterSync): void
    {
    }
}

Trade-off of the alternative: rules that condition on quantity_and_stock_status stop reacting to stock changes until the next scheduled reindex — i.e. you give back exactly what ACP2E-2805 added. If no active rule uses that attribute it is free; if one does, it is a regression. What it buys is keeping the synchronous catalog-rule reindex — and the copy-and-swap window described above — out of the stock-push request entirely.

<item name="ruleIndexUpdateProcessor" xsi:type="null"/> does not work here, and is worth flagging as a separate DI usability problem: a null item keeps the key in the array with a null value instead of removing it, and SkuListsProcessor::__construct() sorts the pool with a closure typed against CompositeProductProcessorInterface under strict_types=1, so the null raises a TypeError on every single stock push. reindexList() then iterates the same pool calling $processor->process(...), which is a second failure point. Pools in core that do accept a null item (e.g. CatalogImportExport's StockProcessor) call array_filter() in the constructor; this one does not.

Additional information

No Adobe quality patch addresses this. None of the available patches touch InventoryCatalogRule, RuleIndexUpdateProcessor or CatalogRuleConfigurable/etc/*. The closest by title, ACSD-63572 ("CatalogRule indexer temporary tables aren't cleaned up if the indexer process is terminated"), declares >=2.4.5 <2.4.8 and is unrelated.

Reproduced on a production-equivalent staging environment (2.4.9): pushing stock back to a child SKU of a configurable that matches an active category-based rule reliably removes its catalogrule_product rows.

Release note

Fixed an issue where configurable products permanently lost their catalog price rule discount after a stock update through the REST API.