AI Reports

Magento 2 troubleshooting › Stock and inventory

Why does a configurable product show out of stock when its variants are in stock?

Short answer: A configurable product is in stock only if at least one child is enabled, assigned to the website, and salable, and the parent's own stock flag is In Stock. Check the children first, then the parent.

Check it step by step

These queries only read data. Run them on a copy of your database if you can, or ask your developer to. If your tables have a prefix (set in app/etc/env.php), add it to each table name.

1. The children: status, website and stock

Magento Open Source

SET @sku = 'ABC-123';  -- your SKU
SELECT c.sku AS child_sku, st.value AS status, si.qty, si.is_in_stock,
       (SELECT GROUP_CONCAT(pw.website_id) FROM catalog_product_website pw WHERE pw.product_id = c.entity_id) AS websites
FROM catalog_product_entity p
JOIN catalog_product_super_link l ON l.parent_id = p.entity_id
JOIN catalog_product_entity c ON c.entity_id = l.product_id
JOIN eav_entity_type t ON t.entity_type_code = 'catalog_product'
JOIN eav_attribute a_status ON a_status.entity_type_id = t.entity_type_id AND a_status.attribute_code = 'status'
LEFT JOIN catalog_product_entity_int st ON st.entity_id = c.entity_id AND st.attribute_id = a_status.attribute_id AND st.store_id = 0
LEFT JOIN cataloginventory_stock_item si ON si.product_id = c.entity_id
WHERE p.sku = @sku;

Adobe Commerce

Product, category, rule and CMS values are stored per version and joined on row_id (why):

SET @sku = 'ABC-123';  -- your SKU
SELECT c.sku AS child_sku, st.value AS status, si.qty, si.is_in_stock,
       (SELECT GROUP_CONCAT(pw.website_id) FROM catalog_product_website pw WHERE pw.product_id = c.entity_id) AS websites
FROM catalog_product_entity p
JOIN catalog_product_super_link l ON l.parent_id = p.row_id
JOIN catalog_product_entity c ON c.entity_id = l.product_id
  AND c.created_in <= UNIX_TIMESTAMP() AND c.updated_in > UNIX_TIMESTAMP()
JOIN eav_entity_type t ON t.entity_type_code = 'catalog_product'
JOIN eav_attribute a_status ON a_status.entity_type_id = t.entity_type_id AND a_status.attribute_code = 'status'
LEFT JOIN catalog_product_entity_int st ON st.row_id = c.row_id AND st.attribute_id = a_status.attribute_id AND st.store_id = 0
LEFT JOIN cataloginventory_stock_item si ON si.product_id = c.entity_id
WHERE p.sku = @sku
  AND p.created_in <= UNIX_TIMESTAMP() AND p.updated_in > UNIX_TIMESTAMP();

Status 1 is enabled, 2 disabled. A child that's enabled and in stock but not on the website doesn't count for that website.

2. The parent's own stock flag

The parent has its own stock item. If someone set it to Out of Stock, the product shows out of stock whatever the children have.

Works on Magento Open Source and Adobe Commerce:

SET @sku = 'ABC-123';  -- your SKU
SELECT e.sku, si.is_in_stock, si.qty
FROM catalog_product_entity e
JOIN cataloginventory_stock_item si ON si.product_id = e.entity_id
WHERE e.sku = @sku;

3. What the storefront index says

Works on Magento Open Source and Adobe Commerce:

SET @sku = 'ABC-123';  -- your SKU
SELECT sku, quantity, is_salable
FROM inventory_stock_1
WHERE sku = @sku;

How to fix it

Related

Gaurav Harsh

Gaurav Harsh is a Magento developer who works on large Adobe Commerce stores and builds AI Reports, a Magento extension for asking your store's data questions in plain English. LinkedIn