In Magento, multiselect attribute values are saved as comma separated values.
For example, an arbitrary multiselect attribute id “my_option” has the following values:
1. Option1
2. Option2
3. Option3
We need to load the product by ID or by SKU. Once, a product object is loaded, to update the attribute value, do the following code:
<?php
//save multiselcet product attribute values
$attrCode = ‘my_options';
$sourceModel = Mage::getModel('catalog/product')
->getResource()
->getAttribute($attrCode)
->getSource();
$valuesText = explode(',', 'Option1,Option2');
$valuesIds = array_map(array($sourceModel, 'getOptionId'), $valuesText);
$_product->setData($attrCode, $valuesIds);
$_product->save();
?>
That’s all.
Cheers!