Skip to content

Instantly share code, notes, and snippets.

@tegansnyder
Created January 8, 2014 03:18
Show Gist options
  • Select an option

  • Save tegansnyder/8311225 to your computer and use it in GitHub Desktop.

Select an option

Save tegansnyder/8311225 to your computer and use it in GitHub Desktop.
Get list of skus and their corresponding category_ids with direct SQL Magento.
SELECT sku, GROUP_CONCAT(entity_id) as category_ids FROM (
SELECT c3.sku, c2.entity_id
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)
) main
GROUP BY sku
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment