Question

I have created product custom attribute called package which is multiselect.

$this->addAttribute(
    'catalog_product',
    'packages',
    array(
        'group'             => 'Package',
        'backend'           => '',
        'frontend'          => '',
        'class'             => '',
        'default'           => '',
        'label'             => 'Packages',
        'input'             => 'multiselect',
        'type'              => 'text',
        'source'            => 'npm_recurrex/package_source',
        'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
        'is_visible'        => 1,
        'required'          => 0,
        'searchable'        => 0,
        'filterable'        => 0,
        'unique'            => 0,
        'comparable'        => 0,
        'visible_on_front'  => 1,
        'user_defined'      => 1,
    )
);

And the options for this fields get from the custom module called package where I create/edit the package entity.

enter image description here

Everything is fine, but only problem is When I am saving a product with custom attribute I am selecting multiple options, I mean I am selection package1 and package2 and save the product. Product saved successfully, but this is not saving my custom attribute selected values, custom attribute [multi select] not storing in database.

Can anybody suggest what is the wrong with this, Where I am not good in this process?

Thank you for valuable answers

Was it helpful?

Solution

You have to make sure, that magento changes your values to something which can be written to the database, an array can't.

so you need to add a backend model:

'backend'       => 'eav/entity_attribute_backend_array',

More on stackoverflow

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top