Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Magento change dropdown attribute to multiselect
-- 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;
-- Next, copy the attribute values from the old table to the new one
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;
-- 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;
/*
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 column "eav_entity_type" in table "eav_attribute"
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.
*/
@ADDISON74

This comment has been minimized.

Copy link

ADDISON74 commented Jan 21, 2017

in your UPDATE statement add this too:

source_model = 'NULL'

for a dropdown attribute type the value is 'eav/entity_attribute_source_table'

@mageconsult

This comment has been minimized.

Copy link

mageconsult commented May 25, 2018

For usage with Magento >= 1.9.3 take a look at https://gist.github.com/mageconsult/733d6851e41aec42f19c8aeeef004268

And please use source_model = NULL without quote signs, that will bring an error "Source-Model "NULL" not found" in your magento backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.