1

I have created a custom dropdown-attribute for magento category with few option, Now I want to add one more option to this select attribute. Is there any way to do this without deleting the existing attribute.

 $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
 $setup->startSetup();
 $setup->addAttribute('catalog_category', 'price_base_unit', array(
 'group' => 'Order Units',
 'input' => 'select',
 'type' => 'varchar',
 'option' => array ('value' => array(
 'optionone'=> array(
 0 =>'Bag'),
 'optiontwo'=> array(
 0 =>'Kg'),
 'optionthree'=> array(
 0 =>'Piece'),
 'optionfour'=> array(
 0 =>'Sq. ft'),
 'optionfive'=> array(
 0 =>'Cu. ft'),
 'optionsix'=> array(
 0 =>'litre'))),
 'label' => 'Price base unit',
 'backend' => '',
 'visible' => 1,
 'required' => 0,
 'user_defined' => 1,
 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
 ));
 $setup->endSetup();
asked Jun 8, 2016 at 9:05
1
  • Can you share,custom dropdown-attribute installer code? Commented Jun 8, 2016 at 9:27

1 Answer 1

1

Try to use the following code snippet

 $attrModel = Mage::getModel('catalog/resource_eav_attribute')->loadByCode('catalog_category', 'price_base_unit');
 $option['attribute_id'] = $attrModel->getAttributeId();
 $option['value']['new_option'][0] = 'new_option_value';
 $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
 $setup->addAttributeOption($option);
answered Jun 9, 2016 at 10:52

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.