Skip to main content

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' =>
  array          array(
                'values' =>
    array                array(
                        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']);
}

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' =>
  array (
    'values' =>
    array (
      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']);
}

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' =>
            array(
                'values' =>
                    array(
                        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']);
}
Source Link

Admin customer set option_id

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' =>
  array (
    'values' =>
    array (
      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']);
}