Last active
October 14, 2019 19:52
-
-
Save dvdmierden/06ef074724848d86dc7a543773c088f9 to your computer and use it in GitHub Desktop.
Magento 1 Find unused manufacturers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT v.value | |
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" | |
AND a.attribute_code = 'manufacturer' | |
ORDER BY v.value |
Can also be used to delete all orphan attribute option values by replacing "SELECT v.value" with "DELETE v"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can be used to find orphan attribute values. Just replace 'manufacturer' with appropriate attribute option value