Magento 2 SQL queries › Products and catalogue
Which products have a price of 0?
Short answer: Filter the product grid by price 0 to 0. It misses products with no price row at all; the query catches both.
In the Magento admin
- Go to Catalog › Products › Filters and set Price from 0 to 0.
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, pr.value AS price
FROM catalog_product_entity e
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'
JOIN eav_attribute a_price ON a_price.entity_type_id = t.entity_type_id AND a_price.attribute_code = 'price'
JOIN catalog_product_entity_int st ON st.entity_id = e.entity_id AND st.attribute_id = a_status.attribute_id AND st.store_id = 0 AND st.value = 1
LEFT JOIN catalog_product_entity_decimal pr ON pr.entity_id = e.entity_id AND pr.attribute_id = a_price.attribute_id AND pr.store_id = 0
WHERE e.type_id IN ('simple', 'virtual', 'downloadable')
AND (pr.value IS NULL OR pr.value = 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, e.type_id AS type, pr.value AS price
FROM catalog_product_entity e
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'
JOIN eav_attribute a_price ON a_price.entity_type_id = t.entity_type_id AND a_price.attribute_code = 'price'
JOIN catalog_product_entity_int st ON st.row_id = e.row_id AND st.attribute_id = a_status.attribute_id AND st.store_id = 0 AND st.value = 1
LEFT JOIN catalog_product_entity_decimal pr ON pr.row_id = e.row_id AND pr.attribute_id = a_price.attribute_id AND pr.store_id = 0
WHERE e.type_id IN ('simple', 'virtual', 'downloadable')
AND (pr.value IS NULL OR pr.value = 0)
AND e.created_in <= UNIX_TIMESTAMP() AND e.updated_in > UNIX_TIMESTAMP()
ORDER BY e.sku;
Good to know
- Configurable and dynamic-price bundle products take their price from their children, so they're skipped.
- If Catalog Price Scope is set to Website, prices can also be stored per website (
store_id> 0). A 0 here may be overridden there. - A price of 0 can be deliberate, for free samples or items priced by options.