Created
August 26, 2015 15:17
-
-
Save hughgrigg/5f3d708862553972a5a6 to your computer and use it in GitHub Desktop.
Convert Magento drop-down attribute into varchar attribute
This file contains 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
INSERT INTO catalog_product_entity_varchar | |
(entity_type_id, attribute_id, store_id, entity_id, `value`) | |
SELECT | |
4 AS entity_type_id, | |
216 AS attribute_id, | |
`existing_value`.store_id, | |
`existing_option_id`.entity_id, | |
`existing_value`.`value` | |
FROM `eav_attribute_option_value` AS `existing_value` | |
INNER JOIN catalog_product_entity_int AS `existing_option_id` | |
ON `existing_option_id`.`value` = `existing_value`.option_id | |
WHERE `existing_value`.option_id IN ( | |
SELECT option_id | |
FROM eav_attribute_option AS att_option | |
WHERE att_option.attribute_id = 216 | |
) | |
ON DUPLICATE KEY UPDATE catalog_product_entity_varchar.entity_id = catalog_product_entity_varchar.entity_id; | |
DELETE FROM catalog_product_entity_int | |
WHERE attribute_id = 216; | |
UPDATE eav_attribute | |
SET backend_type = 'varchar' | |
WHERE attribute_id = 216; | |
UPDATE catalog_eav_attribute | |
SET is_global = 0 | |
WHERE attribute_id = 216; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment