3

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

dotancohen
1,1306 silver badges21 bronze badges
asked Jun 1, 2015 at 12:26

1 Answer 1

2

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

answered Jun 1, 2015 at 12:35
0

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.