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();
  • Can you share,custom dropdown-attribute installer code? – Amit Bera Jun 8 '16 at 9:27
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);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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