Magento Forum

   
How to modify a multi select attribute value for a product
 
geek59600
Jr. Member
 
Total Posts:  4
Joined:  2012-08-06
 

Good Afternoon,

I need to set a multi select value for all my products.
I’ve found some informations and try one :

$tmpProd->setData('myAttribute', (string)"5632");
$tmpProd->save();

Where 5632 is the Id of one value of the multiSelect Attribute.

It Works BUT, if i go to the product page in backend it’s note the good value wich is selected ; and if i change the value from the backend it doesn’t work now it seem that they are “desyncronised”

Can you help me ?
Thank a lot.

Edit i think, i’have found why but i don’t know how to fix it.
The Multi select attribute has been created after the product so here’s the problem.

To display information I use this code :

$tmpProd Mage::getModel('catalog/product')->load($productId);
    echo(
"<pre>");
    
var_dump($tmpProd->getData());
    echo (
"</pre>");

Before i set in the product page a value for the multiselect attribute i have this output from var_dump(getData()) :
http://pastebin.com/T506H9aS
In this output, my attribute ‘moto_compatible’ is missing.

After i set a value for the attribute i have this output
http://pastebin.com/wCxiKqUy
In this output, my attribute ‘moto_compatible’ appear once.

And if I try to use a code like

$tmpProd->addAttributeUpdate('moto_compatible',  "5632"1);
$tmpProd->validate();
Here’s the new var_dump() output
http://pastebin.com/6s70z3JV

‘moto_compatible’ appear twice without the same value.

The first one near row 58 is the “effective” (i check using filter)
The second near row 594 is the value which is displayed in the product page (backend )

If i try to change value from backend it don’t work only the “displayed value” change but not the effective ...
And if i change the effective with

addAttributeUpdate
the displayed value don’t change

Have you an idea, it’s a headache for me.

Thank again.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top