Problem:
Create a simple custom multi select customer attribute programmatically via upgrade script.
Solution:
$attributeCode = 'my_attribute';
$installer->addAttribute('customer', $attributeCode, array(
'type' => 'varchar',
'label' => 'My Attribute',
'input' => 'multiselect',
'source' => 'eav/entity_attribute_source_table',
'backend' => '',
'visible' => false,
'required' => false,
'unique' => false,
'option' => array (
'value' => array(
'Option1' => array('Option1'),
'Option2' => array('Option2')
)
)
));
$attribute = Mage::getSingleton('eav/config')
->getAttribute('customer', $attributeCode);
$attribute
->setData('used_in_forms', array('customer_account_edit'))
->setData('is_used_for_customer_segment', true)
->setData('is_system', false)
->setData('is_user_defined', true)
->setData('is_visible', false)
->setData('sort_order', 100);
$attribute->save();
No comments:
Post a Comment