Magento – Find out to which categories a product belongs to

backendcatalogcategorymagento-1product

I opened a product in the backend, but when I switch to the categories tab, the category tree is fully collapsed. I would have to expand all categories to see in which ones the product is in.

How can I quickly see (in the backend) to which categories the product belongs?

Best Answer

There is no core functionality to archive this in the backend.

If you have database read access to run raw queries you can use the following queries to get an overview of all the categories that are linked to a certain product:

Option 1 => Get all categories of a product by entering the product's entity ID:

SELECT c3.sku, c2.value
FROM catalog_category_product c1
INNER JOIN catalog_category_entity_varchar c2 ON (c1.category_id = c2.entity_id)
INNER JOIN catalog_product_entity c3 ON (c1.product_id = c3.entity_id)
WHERE c2.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'name' AND entity_type_id = 3)
AND c3.entity_id = FILL_IN_PRODUCT_ID_HERE

Option 2 => Get all categories of a product by entering the product's SKU:

SELECT c3.sku, c2.value
FROM catalog_category_product c1
INNER JOIN catalog_category_entity_varchar c2 ON (c1.category_id = c2.entity_id)
INNER JOIN catalog_product_entity c3 ON (c1.product_id = c3.entity_id)
WHERE c2.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'name' AND entity_type_id = 3)
AND c3.sku = FILL_IN_PRODUCT_SKU_HERE
Related Topic