Skip to content

Instantly share code, notes, and snippets.

@zdravkok
Created May 19, 2014 12:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zdravkok/d34ae4607950e4931a64 to your computer and use it in GitHub Desktop.
Save zdravkok/d34ae4607950e4931a64 to your computer and use it in GitHub Desktop.
Delete unused attribute values from Magento
DELETE o, v
FROM eav_attribute a
INNER JOIN eav_attribute_option o ON a.attribute_id = o.attribute_id
INNER JOIN eav_attribute_option_value v ON v.option_id = o.option_id
INNER JOIN eav_entity_type t ON t.entity_type_id = a.entity_type_id
LEFT JOIN catalog_product_entity_int pi ON o.option_id = pi.value AND o.attribute_id = pi.attribute_id
LEFT JOIN catalog_product_entity_varchar pv ON o.option_id = pv.value AND o.attribute_id = pv.attribute_id
WHERE pi.entity_id IS NULL
AND pv.entity_id IS NULL
AND t.entity_type_code = "catalog_product"
@r-martins
Copy link

Very good. Thanks for sharing.

@vpietri
Copy link

vpietri commented Mar 24, 2016

Seems you forget to post a link back to the source : Stack Exchange

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment