For all enquiries please call or email us. 01484 506220info@designthatfits.co.uk

Magento - Removing Unused Product Attributes

From time to time it's necessary on larger Magento website to clean up the product attributes section.
Jun 18, 2015
From time to time it's necessary on larger Magento website to clean up the product attributes section.

Magento doesn't unfortunately provide anything out of the box to check whether attribute options have been used, in our particular case we had a lot of duplicated options that had been created by a third party integration and we needed to remove any that weren't in use.

We turned to google and came across a Stack Exchange question here.

In case the question ever disappears we've copied the answer that worked for us here. Please be careful when running this sql command, we'd suggest testing it on a development/staging version of your website and then rolling out the changes from their - and as always make sure you backup your site before you run anything like this:

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"

Return to articles
Fishpig's Wordpress extension was a key part of any magento 1.9.x project. This hasn't changed with Magento 2, but...
Marketing automation is a great asset for any business and once set up requires very little maintaining.
If you use plesk to run Magento 2 you might find difficulty when you come to run bin/magento commands
We'd suggest adding address lookup to the checkout.

Businesses can trust us to deliver effective online marketing solutions. Find out why.

Speak to an expert