[PaaS only]{class="badge informative" title="Applies to Adobe Commerce on Cloud projects (Adobe-managed PaaS infrastructure) and on-premises projects only."}

ACSD-67166: Duplicate execution of the cataloginventory_stock_status query when loading a quote on the storefront

The ACSD-67166 patch fixes the issue where duplicate execution of the cataloginventory_stock_status query occurs when loading a quote on the storefront, causing redundant DB calls. This patch is available when the Quality Patches Tool (QPT) 1.1.70 is installed. The patch ID is ACSD-67166. Please note that this issue is scheduled to be fixed in Adobe Commerce 2.4.9.

Affected products and versions

The patch is created for Adobe Commerce version:

  • Adobe Commerce (all deployment methods) 2.4.5-p13

Compatible with Adobe Commerce versions:

  • Adobe Commerce (all deployment methods) 2.4.4 - 2.4.8-p2
NOTE
The patch might become applicable to other versions with new Quality Patches Tool releases. To check if the patch is compatible with your Adobe Commerce version, update the magento/quality-patches package to the latest version and check the compatibility on the Quality Patches Tool: Search for patches page. Use the patch ID as a search keyword to locate the patch.

Issue

Duplicate execution of the cataloginventory_stock_status query occurs when loading a quote on the storefront, causing redundant DB calls.

Steps to reproduce:

  1. Install a clean instance.

  2. Create a Category and a Simple Product.

  3. Go to the category and add a product to the cart.

  4. Go to the cart page: /checkout/cart/

  5. Set breakpoints in xDebug:

    1. app/code/Magento/CatalogInventory/Model/StockRegistryPreloader.php:115
    2. app/code/Magento/InventoryCatalog/Model/LegacyStockStatusCache.php:73
    3. lib/internal/Magento/Framework/Data/AbstractSearchResult.php:233
    4. Breakpoint Condition: strpos($this->query->getSelectSql(true), 'stock_status') !==false
      Add $_SERVER['REQUEST_URI'] to watches in PHPStorm to verify the query is called twice within the same request.

Expected results:

The query is executed once per request.

Actual results:

The same query is executed twice:

SELECT `main_table`.*, `cp_table`.`sku`, `cp_table`.`type_id` FROM `cataloginventory_stock_status` AS `main_table`
 INNER JOIN `catalog_product_entity` AS `cp_table` ON main_table.product_id = cp_table.entity_id AND (cp_table.created_in <= 1 AND cp_table.updated_in > 1) WHERE (`main_table`.`product_id` IN(2)) AND (`main_table`.`website_id` = '0')

Apply the patch

To apply individual patches, use the following links depending on your deployment method:

To learn more about Quality Patches Tool, refer to:

recommendation-more-help
c2d96e17-5179-455c-ad3a-e1697bb4e8c3