Skip to content

Instantly share code, notes, and snippets.

@xyn22
Created July 23, 2015 22:42
Show Gist options
  • Save xyn22/72f9812557a735891649 to your computer and use it in GitHub Desktop.
Save xyn22/72f9812557a735891649 to your computer and use it in GitHub Desktop.
Magento - add an attribute option in setup script
<?php
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$attr_model = Mage::getModel('catalog/resource_eav_attribute');
$attr = $attr_model->loadByCode('customer', $attribute_name);
$attr_id = $attr->getAttributeId();
$option = array('attribute_id' => $attr_id, 'values' => array(1000 => $option_label));
$setup->addAttributeOption($option);
$installer->endSetup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment