AI Reports

Magento 2 SQL queries › Products and catalogue

Which configurable products have no variant in stock?

Short answer: A configurable product is sellable only through its variants. Find parents where no linked child is in stock.

In the Magento admin

  1. Open each configurable product and check the Configurations grid for quantity and status.

With one query

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.

Magento Open Source

SELECT e.sku
FROM catalog_product_entity e
WHERE e.type_id = 'configurable'
  AND NOT EXISTS (
    SELECT 1
    FROM catalog_product_super_link l
    JOIN cataloginventory_stock_item si ON si.product_id = l.product_id
    WHERE l.parent_id = e.entity_id AND si.is_in_stock = 1 AND si.qty > 0
  )
ORDER BY e.sku;

Adobe Commerce

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

SELECT e.sku
FROM catalog_product_entity e
WHERE e.type_id = 'configurable'
  AND e.created_in <= UNIX_TIMESTAMP() AND e.updated_in > UNIX_TIMESTAMP()
  AND NOT EXISTS (
    SELECT 1
    FROM catalog_product_super_link l
    JOIN cataloginventory_stock_item si ON si.product_id = l.product_id
    WHERE l.parent_id = e.row_id AND si.is_in_stock = 1 AND si.qty > 0
  )
ORDER BY e.sku;

Good to know

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