Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
List the Magento Skus and the Category Paths they belong in

Find a list of magento sku's and the category paths they belong in via MySQL query.

SELECT product_id, sku, catid, cce.path FROM (
    SELECT entity_id as product_id, category_id as catid FROM (
        SELECT `e`.entity_id, `at_category_id`.`category_id` 
        FROM `catalog_product_entity` AS `e` 
        LEFT JOIN `catalog_category_product` AS `at_category_id`
        ON (at_category_id.`product_id`=e.entity_id)
    ) sub_query
) final_query
INNER JOIN `catalog_category_entity` as `cce` on cce.entity_id = catid 
INNER JOIN `catalog_product_entity` as `cpe` on cpe.entity_id = product_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.