Created
September 29, 2016 07:15
-
-
Save LogIN-/d896dce1be48e0ff3f52e432bb47a47e to your computer and use it in GitHub Desktop.
Delete Magneto attribute by Attribute-Code
This file contains hidden or 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
| <?php | |
| /** | |
| * Attribute codes to delete | |
| */ | |
| $attribute_codes = array('color', 'size', 'filter_color'); | |
| foreach ($attribute_codes as $attribute_code) { | |
| $attribute = \Mage::getModel('eav/config')->getAttribute('catalog_product', $attribute_code); | |
| $options = $attribute->getSource()->getAllOptions(); | |
| $optionsDelete = array(); | |
| foreach ($options as $option) { | |
| if ($option['value'] != "") { | |
| $optionsDelete['delete'][$option['value']] = true; | |
| $optionsDelete['value'][$option['value']] = true; | |
| } | |
| } | |
| $installer = new \Mage_Eav_Model_Entity_Setup('core_setup'); | |
| $installer->addAttributeOption($optionsDelete); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment