Skip to content

Instantly share code, notes, and snippets.

@LogIN-
Created September 29, 2016 07:15
Show Gist options
  • Select an option

  • Save LogIN-/d896dce1be48e0ff3f52e432bb47a47e to your computer and use it in GitHub Desktop.

Select an option

Save LogIN-/d896dce1be48e0ff3f52e432bb47a47e to your computer and use it in GitHub Desktop.
Delete Magneto attribute by Attribute-Code
<?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