Do you know why magento saves multiselect attribute type as varchar and relative product assocations in catalog_product_entity_varchar as array?

With array is not possible join between catalog_product_entity_varchar and eav_attribute_option_value on value=option_id

when value is varchar like 1,2,3, because option_id is int.

Isn't better considerer multiselect as multiple int and insert multiple record in catalog_product_entity_int?

So is possible join correctly catalog_product_entity_int and eav_attribute_option_value on value=option_id

  • 1
    I think that magento saves multiselect values in a string comma separated and not in multi int values, because it is stored in a single record and it is easier to handle.
    – KamL
    Apr 2, 2019 at 13:24

1 Answer 1


Multiselect attributes can be set as a comma separated list (or also an array) containing the attribute value ids.

So first we have to convert the actual values to Magento's internal ids. try this code:-

$attrCode = 'color_base';
$sourceModel = Mage::getModel('catalog/product')->getResource()
$valuesText = explode(',', 'red,green,blue');
$valuesIds = array_map(array($sourceModel, 'getOptionId'), $valuesText);
$product->setData($attrCode, $valuesIds);


  • is possible to avoid that magento saves it as a comma separeted list and save it directly as single int like dropdown?
    – LucScu
    Jul 3, 2015 at 10:33
  • yes try it possible Jul 3, 2015 at 10:34
  • and visit link swarminglabs.com/… Jul 3, 2015 at 10:37
  • Ok, i try your code, but why magento don't has this logic by default and i have to do it with a custom code? My question was: why they use this logic to save multiselect in array?
    – LucScu
    Jul 3, 2015 at 10:39
  • i have begin in magento Jul 3, 2015 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.