Magento 2 SQL queries › Stock
Which products have never sold?
Short answer: No report shows this. Look for products with no line in sales_order_item.
In the Magento admin
- Compare the Bestsellers or Products Ordered report with a product export. Slow on big catalogues.
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, e.type_id AS type, e.created_at
FROM catalog_product_entity e
WHERE e.type_id IN ('simple', 'virtual', 'downloadable')
AND NOT EXISTS (SELECT 1 FROM sales_order_item i WHERE i.product_id = e.entity_id)
ORDER BY e.created_at;
Adobe Commerce
Product, category, rule and CMS values are stored per version and joined on row_id (why):
SELECT e.sku, e.type_id AS type, e.created_at
FROM catalog_product_entity e
WHERE e.type_id IN ('simple', 'virtual', 'downloadable')
AND NOT EXISTS (SELECT 1 FROM sales_order_item i WHERE i.product_id = e.entity_id)
AND e.created_in <= UNIX_TIMESTAMP() AND e.updated_in > UNIX_TIMESTAMP()
ORDER BY e.created_at;
Good to know
- Sales of a configurable product are recorded on both the parent and the child line, so variants that sold are not listed.
- Orders deleted by an extension or a clean-up script no longer count.