1

I have created one custom module with add associated products concept. Created successfully. Its working Good too.

But when i add "Multi select attribute" column in product grid with that option values, That entity value not saved.

enter image description here

If i removed that option value, Its saving fine.

I have shown my code below what i did for add multi select attribute column in product grid

under _prepareColumns() method

 $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'brand');        // attribute code here
    foreach ( $attribute->getSource()->getAllOptions(true, true) as $option)
    {
        if($option['value'] != '')
        $valArr[$option['value']] =  $option['label'];
    }


$this->addColumn('brand', array(
        'header'=> Mage::helper('catalog')->__('Brand'),
        'align' => 'left',
        'index' => 'brand',
        'type'  => 'options',
        'options' => $valArr,


       'renderer'  => 'Mage_Adminhtml_Block_Catalog_Product_Renderer_Brands', // Will have to create the renderer.
       'filter_condition_callback' => array($this, '_filterBrandCondition')
    ));

When i hide 'options' => $valArr, , All are working fine.

I can't able understand, why its happening. Please suggest me your ideas. Thanks in advance.

3

The problem only appears when you click on the "Associated products" tab.
The problem is that if the brand column in the product grid is called 'brand'.
that's the same name used by the fields in the main tab.
All the fields in there are called brand[field_name_here].
The saveAction reads the data necessary for the brand entity like this:

$data = $this->getRequest()->getPost('brand');

But when you access the product grid and then submit the form, the brand field in the grid overrides the values from the main tab.
So instead of the $data variable being an array with values it just has the last value entered as a filter for the brand field in the product grid.

Changing the name of the brand column from the product grid to something else should solve the problem. product_brand for example.

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.