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();
user2638108user2638108
-
Can you share,custom dropdown-attribute installer code?Amit Bera– Amit Bera ♦2016年06月08日 09:27:37 +00:00Commented Jun 8, 2016 at 9:27
1 Answer 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
Explore related questions
See similar questions with these tags.
default