Skip to content

Instantly share code, notes, and snippets.

@willboudle
Created March 14, 2019 23:13
Show Gist options
  • Select an option

  • Save willboudle/ff452789a6fdff7ec30ac54226bd677a to your computer and use it in GitHub Desktop.

Select an option

Save willboudle/ff452789a6fdff7ec30ac54226bd677a to your computer and use it in GitHub Desktop.
Magento 1 SQL list items with options
SELECT e.sku ,t.title AS 'name',cv.value AS 'Custom option name'
,GROUP_CONCAT(ot.title) AS 'Custom option values'
FROM catalog_product_option o
JOIN catalog_product_entity e ON e.entity_id=o.product_id
JOIN catalog_product_option_title t ON t.option_id=o.option_id
JOIN catalog_product_entity_varchar cv ON
cv.entity_id=e.entity_id AND
cv.attribute_id=(SELECT attribute_id
FROM eav_attribute ea
JOIN eav_entity_type et
ON
et.entity_type_code='catalog_product'
AND et.entity_type_id=ea.entity_type_id
WHERE ea.attribute_code='name')
LEFT JOIN catalog_product_option_type_value ov ON
ov.option_id=o.option_id
LEFT JOIN catalog_product_option_type_title ot ON
ot.option_type_id=ov.option_type_id
GROUP BY e.sku, ov.option_id,t.title,cv.value;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment