How to change a product dropdown attribute to a multiselect in Magento

First, update the attribute input type to multiselect:

UPDATE eav_attribute SET
entity_type_id = '4',
attribute_model = NULL,
backend_model = 'eav/entity_attribute_backend_array',
backend_type = 'varchar',
backend_table = NULL,
frontend_model = NULL,
frontend_input = 'multiselect',
frontend_class = NULL
WHERE attribute_id = 'YOUR_ATTRIBUTE_ID_HERE';
Next, copy the attribute values from the old table to the new:
INSERT INTO catalog_product_entity_varchar ( entity_type_id, attribute_id, store_id, entity_id, value)
SELECT entity_type_id, attribute_id, store_id, entity_id, value
FROM catalog_product_entity_int
WHERE attribute_id = YOUR_ATTRIBUTE_ID_HERE;
Finally,  remove the old values or they will conflict with the new setup (the old values will load, but Magento will save new values to the varchar table):
DELETE FROM catalog_product_entity_int
WHERE entity_type_id = 4 and attribute_id = YOUR_ATTRIBUTE_ID_HERE;
Credit to Meabed's post for the initial concept: http://www.meabed.net/2012/10/18/convert-attribute-drop-down-to-multiselect-magento.html Update regarding entity_type_id value referenced in the above example: The value for "entity_type_id" that you'll want to use may not always be "4" as referenced above. You'll want to check the table "eav_entity_type" and find the entry that has the "entity_type_code" set to "catalog_product". The "entity_type_id" for that record is the value you need to use. In most cases this value is either "4" or "10", but this may vary in future versions of Magento. Thanks to David Line for the heads up and providing these instructions.

8 thoughts on “How to change a product dropdown attribute to a multiselect in Magento”

  • Strumdude

    Hi Ian
    I am a relative newbie to all things Mangento/PHP and SQL, so a little knowledge is a dangerous thing! I have set the manufacturer attribute to dropdown, but after uploading 8000 products I have realised that Multi-select will be better.

    Please can you confirm that all I need to change in the code is the ATTRIBUTE ID.

    Thanks

    Reply
    • Ian Baxter

      If you replace all instances of YOUR_ATTRIBUTE_ID_HERE with the attribute ID of the field you would like to convert to a multi-select field, the example I outlined should work. I’ve used this example multiple times with good success. Regardless, I highly recommend that you first backup your database before proceeding.

      Reply
  • Dmitry

    Just confirming that it worked for me in Magento 1.7. Thanks Ian.

    Reply
  • Anand

    Thanks a lot. It works perfectly.

    Reply
  • Bhargav

    What is the use of last code as i am bit confused that why is it used?

    Reply
  • David Line

    One thing you want to watch out for is the "entity_type_id = '4'

    On some of my Magento installations this value is actually '10'

    You can check what value your Magento Install uses by looking at the table "eav_entity_type" and finding the table entry that has the "entity_type_code" field set to "catalog_product". The "entity_type_id" for that record is the value you need to use. In most cases this value is either "4" or "10". I have more installs that use "10" actually. I have never seen any other values, but there certainly could be.

    Good Luck

    Reply
  • golan

    hi

    i dont understand why using entity_type_id = '4',

    as type 4 in my sql is sales / orders.
    For products its used 10

    pls can you explain whyt you set 4?

    Reply
  • Ian Baxter

    Thanks for the comment David. I'll update the post to make it clear that entity_type_id may not always be '4'.

    Cheers,
    Ian

    Reply
Leave a Reply