I have a product attribute that is currently produces varchar(255)
as a Type in catalog_product
flat tables. How do I change it to being type int(11)
programatically? Do I just remove an attribute and re-add it via setup script or there is another way?
-
Which your Magento version?– Khoa TruongDinhCommented Jul 22, 2016 at 16:27
-
Magento ver. 1.14– ifrmCommented Jul 22, 2016 at 16:31
2 Answers
- Create new attribute
- Insert new values or copy values from old attribute
- Delete old attribute
- (Optional) If you like rename old attribute.
-
1
Although technically you could directly modify the attribute in the eav_attribute table, the real problem is that the combination product - attribute - value is actually in catalog_product_entity_varchar. So, change attribute type, implicates that all the stored in catalog_product_entity_varchar as varchar(255) would have to be moved to catalog_product_entity_int and converted to int(11). Therefore, there is as such an automatic and enjoyable way to do this, except, indeed, delete and recreate it.
To keep all information already captured in each product, you should perhaps try to export the data, delete the attribute, create it again with the same name, and then re-import the CSV.