Magento 2 troubleshooting › Catalogue
Which categories are enabled but have no products?
Short answer: A category with no products, directly or in any subcategory, shows “We can't find products matching the selection” to shoppers. The query finds enabled categories where nothing is assigned anywhere under them.
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.
Enabled categories with nothing assigned under them
Magento Open Source
SELECT c.entity_id, nm.value AS category, c.path
FROM catalog_category_entity c
JOIN eav_entity_type t ON t.entity_type_code = 'catalog_category'
JOIN eav_attribute a_is_active ON a_is_active.entity_type_id = t.entity_type_id AND a_is_active.attribute_code = 'is_active'
JOIN eav_attribute a_name ON a_name.entity_type_id = t.entity_type_id AND a_name.attribute_code = 'name'
JOIN catalog_category_entity_int act ON act.entity_id = c.entity_id AND act.attribute_id = a_is_active.attribute_id AND act.store_id = 0 AND act.value = 1
LEFT JOIN catalog_category_entity_varchar nm ON nm.entity_id = c.entity_id AND nm.attribute_id = a_name.attribute_id AND nm.store_id = 0
WHERE c.level >= 2
AND NOT EXISTS (
SELECT 1 FROM catalog_category_product cp
JOIN catalog_category_entity cc ON cc.entity_id = cp.category_id
WHERE cc.entity_id = c.entity_id OR cc.path LIKE CONCAT(c.path, '/%')
)
ORDER BY c.path;
Adobe Commerce
Product, category, rule and CMS values are stored per version and joined on row_id (why):
SELECT c.entity_id, nm.value AS category, c.path
FROM catalog_category_entity c
JOIN eav_entity_type t ON t.entity_type_code = 'catalog_category'
JOIN eav_attribute a_is_active ON a_is_active.entity_type_id = t.entity_type_id AND a_is_active.attribute_code = 'is_active'
JOIN eav_attribute a_name ON a_name.entity_type_id = t.entity_type_id AND a_name.attribute_code = 'name'
JOIN catalog_category_entity_int act ON act.row_id = c.row_id AND act.attribute_id = a_is_active.attribute_id AND act.store_id = 0 AND act.value = 1
LEFT JOIN catalog_category_entity_varchar nm ON nm.row_id = c.row_id AND nm.attribute_id = a_name.attribute_id AND nm.store_id = 0
WHERE c.level >= 2
AND c.created_in <= UNIX_TIMESTAMP() AND c.updated_in > UNIX_TIMESTAMP()
AND NOT EXISTS (
SELECT 1 FROM catalog_category_product cp
JOIN catalog_category_entity cc ON cc.entity_id = cp.category_id
WHERE cc.entity_id = c.entity_id OR cc.path LIKE CONCAT(c.path, '/%')
)
ORDER BY c.path;
Level 0 and 1 are the tree root and the store roots, so they're skipped. A category can also look empty when its products are disabled, invisible or out of stock; those are shown in the category's product list in the admin but not on the storefront. Categories with Display Mode set to Static block only are content pages and are meant to have no products.
How to fix it
- Assign products, disable the category (Enable Category = No), or remove it from the menu (Include in Menu = No).
- If products are assigned but the page is still empty, see product not showing on its category page.