Forked from dinhkhanh/change-dropdown-attribute-to-multiselect.sql
Last active
August 15, 2017 00:14
-
-
Save trabulium/5a27117b6b5511fd6dda22583a4f4df6 to your computer and use it in GitHub Desktop.
Magento change dropdown attribute to multiselect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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', | |
source_model = NULL, | |
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. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment