AI Reports

Magento 2 SQL queries › Products and catalogue

How many products are in each attribute set?

Short answer: Filter the product grid by attribute set and read the count, set by set, or count them all at once.

In the Magento admin

  1. Go to Catalog › Products › Filters, choose one Attribute Set and read the record count.

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 s.attribute_set_name, COUNT(*) AS products
FROM catalog_product_entity e
JOIN eav_attribute_set s ON s.attribute_set_id = e.attribute_set_id
GROUP BY s.attribute_set_id, s.attribute_set_name
ORDER BY products DESC;

Adobe Commerce

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

SELECT s.attribute_set_name, COUNT(*) AS products
FROM catalog_product_entity e
JOIN eav_attribute_set s ON s.attribute_set_id = e.attribute_set_id
WHERE e.created_in <= UNIX_TIMESTAMP() AND e.updated_in > UNIX_TIMESTAMP()
GROUP BY s.attribute_set_id, s.attribute_set_name
ORDER BY products DESC;

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