Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pije76/9c54c00c9a70408fcdba29f9f9361536 to your computer and use it in GitHub Desktop.
Save pije76/9c54c00c9a70408fcdba29f9f9361536 to your computer and use it in GitHub Desktop.
Query to retrieve all product ids and the category they belong to in Magento.
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment