I'm trying to add a custom drop down to my customer in the admin area of Magento. I want to be able to control the option_id for each option in the drop down instead of it just incrementing, how do I go about doing this?

Here is what I've got:

function AddCustomerField($setup, $data)
    $entityTypeId = $setup->getEntityTypeId('customer');
    $attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
    $attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);

    $attr = array(
        'type' => 'varchar',
        'input' => 'select',
        'label' => 'Test',
        'source' => 'eav/entity_attribute_source_table',
        'required' => '0',
        'user_defined' => '1',
        'unique' => '0',
        'global' => '1',
        'visible' => '1',
        'searchable' => '1',
        'filterable' => '1',
        'comparable' => '1',
        'position' => '1',
        'option' =>
                'values' =>
                        999 => 'Green22', // I want the drop down value to be 999 but it just auto increments instead
    $setup->addAttribute('customer', $data['id'], $attr);

    $setup->addAttributeToGroup($entityTypeId, $attributeSetId, $attributeGroupId, $data['id']);

1 Answer 1


If you want control over the values of the dropdown you need to use a source model.

As always, inchoo wrote about this.

To have your own source model extend Mage_Eav_Model_Entity_Attribute_Source_Abstract and implement $_option

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.