We created some "Brands" [values] in backend.
We have around 10 products in one category with category id = "40".
if we open any brand, we are displaying all those category products as multi-select option as below image.
but when we select options and click on "save", its not working.
why we want to save is , if we select particular Brand we want to display selected Products in dropdown in frontend as below image
Below code for displaying list of products in multi-select box.
$products = Mage::getModel('catalog/category')->load(40)
->getProductCollection()
->addAttributeToSelect('*');
$categorylist = array();
$categorylist[] = array(
'value' => '', 'label' => Mage::helper('sales')->__('Category')
);
foreach ($products as $product) {
$categorylist[] = array(
'value' => $product->getEntityId(), 'label' => $product->getName()
);
}
$fieldset->addField('category', 'multiselect',
array(
'label' => Mage::helper('sales')->__('Category'),
'class' => 'required-entry',
'required' => true,
'values' => $categorylist,
'name' => 'category',
));
products of category id : 40
in db'name' => 'category[]',
instead of'name' => 'category',