Skip to content

MSI enabled, but Magento_CatalogInventory observers still trigger (N+1 risk)

MSI enabled, but Magento_CatalogInventory observers still trigger (N+1 risk). Can we rely solely on MSI observers?

Context
We run with MSI enabled, yet Magento_CatalogInventory observers are still active:

<!-- From CatalogInventory -->
<event name="sales_quote_item_collection_products_after_load">
    <observer name="add_stock_items" instance="MagentoCatalogInventoryObserverAddStockItemsObserver"/>
</event>
<event name="sales_quote_item_qty_set_after">
    <observer name="inventory" instance="MagentoCatalogInventoryObserverQuantityValidatorObserver"/>
</event>

MSI also registers:

<event name="sales_quote_item_collection_products_after_load">
    <observer name="inventory_catalog_preload_cache" instance="MagentoInventoryCatalogObserverPreloadCache"/>
</event>

Problem

With MSI, AddStockItemsObserver appears redundant.

MagentoCatalogInventoryObserverQuantityValidatorObserver can still incur N+1 lookups unless stock data is fully preloaded.

We’re seeing performance drag in cart/checkout flows even though MSI should be the source of truth.

Proposal

  1. Disable add_stock_items (CatalogInventory) and rely on MSI’s inventory_catalog_preload_cache.
  2. Optimize or replace MagentoCatalogInventoryObserverQuantityValidatorObserver with an MSI-aware validator that:
    • Uses preloaded stock data,
    • Avoids per-item stock registry calls,
    • Falls back gracefully if preload misses.

Questions

  1. Is it officially supported to disable AddStockItemsObserver when MSI is enabled?
  2. Has the team addressed the slowness/N+1 in QuantityValidatorObserver for MSI setups?

Any recommended best practices or reference implementations for an MSI-native quantity validator?

Goal
Eliminate redundant observers and ensure quantity validation is MSI-native and preload-aware, removing N+1 queries from cart/checkout.