Magento Database – How to Delete Custom EAV Attributes

attributescustom-optionsdatabaseeav

I want to remove unused EAV attributes directly from the database before I move my store live. Attributes can be found in eav_attribute table, can I delete attributes from this table? Is it safe? Or do I also need to edit other EAV tables?

Best Answer

See Mage_Eav_Model_Entity_Setup::removeAttribute(). It takes two arguments - the first is the entity code, and the second is the attribute code.

Edit - to run from a non-installation scope:

<?php
include 'app/Mage.php';
Mage::app();
$setup = Mage::getResourceModel('catalog/setup','catalog_setup');
$setup->removeAttribute('catalog_product','attr_code');
Related Topic