ACP2E-4840: GraphQL products query returns null quantity for in-stock products on custom inventory stocks

The ACP2E-4840 patch fixes the issue where the quantity field in the products GraphQL query returns null for products that are in stock and available for sale on custom inventory stocks. This patch is available when the Quality Patches Tool (QPT) 1.1.82 is installed. The patch ID is ACP2E-4840. Please note that this issue is scheduled to be fixed in Adobe Commerce 2.4.10.

Affected products and versions

The patch is created for Adobe Commerce version:

  • Adobe Commerce (all deployment methods) 2.4.8-p4

Compatible with Adobe Commerce versions:

  • Adobe Commerce (all deployment methods) 2.4.8 - 2.4.8-p5
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

The quantity field in the products GraphQL query returns null for products that are in stock and available for sale on custom inventory stocks.

Prerequisites:

MSI is enabled.

Steps to reproduce:

  1. Create a new source.

  2. On the Admin sidebar, go to Stores > Inventory > Stock.

  3. Click Add New Stock.

  4. Expand Sales Channels and select the Websites where the stock is available.

  5. Expand Sources, click Assign Sources, select the source that you want to assign, and click Done.

  6. On the Admin sidebar, go to Catalog > Products and open an existing product in edit mode.

  7. In the Sources section, assign the custom source, set Source Item Status to In Stock, enter a non-zero value for Qty, and save the product.

  8. Confirm in Catalog > Products that the product shows a non-zero Salable Quantity for the website assigned to the custom stock.

  9. Run the following products GraphQL query for that SKU against the store view assigned to the website that uses the custom stock:

    code language-none
    query {
      products(filter: { sku: { in: ["product_dynamic_1"] } }) {
        items {
          sku
          name
          stock_status
          quantity
          max_sale_qty
        }
      }
    }
    
  10. Observe the response:

    code language-none
    {
      "data": {
        "products": {
          "items": [
            {
              "sku": "product_dynamic_1",
              "name": "Simple Product 1",
              "stock_status": "IN_STOCK",
              "quantity": null,
              "max_sale_qty": 10000
            }
          ]
        }
      }
    }
    

Expected results:

The GraphQL response returns a non-null quantity value for products that are in stock and salable on the current store/website.

Actual results:

The GraphQL response returns quantity = null while stock_status = IN_STOCK for products that are in stock and salable in the Admin when the store uses a custom MSI stock.

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
commerce-operations-help-tools