Last active
March 28, 2019 17:48
-
-
Save jonathansayag/1cb15790feee0b773ebd to your computer and use it in GitHub Desktop.
Magento PHP script to delete all values of an attribute
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
<?php | |
$attribute_code = 'ATTRIBUTE_NAME'; | |
$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
Thank you for example, it helped me to do the same thing on Magento 2: https://gist.github.com/bh-ref/2a788f206f8c3d833e43