stevenyang1011
11/15/2017 - 9:04 PM

Add new options to customer attribute with source

Add new options to customer attribute with source

//the sample is to add an 'unassigned' option to customer gender attribute
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');

$installer->startSetup();

$newOptions = array('unassigned');
$customerAttribute = 'gender';
$customerEntityTypeId = Mage::getModel('customer/customer')->getResource()->getTypeId();

$option = array();
$option['attribute_id'] = $installer->getAttributeId($customerEntityTypeId, $customerAttribute);


for($iCount=0;$iCount<sizeof($newOptions);$iCount++){
    $option['value']['option'.$iCount][0] = $newOptions[$iCount];
}
$installer->addAttributeOption($option);