Skip to content

Instantly share code, notes, and snippets.

@tegansnyder
Created November 20, 2014 14:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tegansnyder/9162b4a12ad041d4b720 to your computer and use it in GitHub Desktop.
Save tegansnyder/9162b4a12ad041d4b720 to your computer and use it in GitHub Desktop.
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