Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

[SOLVED] Change the backend_type for a EAV attribute
 
deXXmd
Jr. Member
 
Total Posts:  24
Joined:  2009-04-15
 

Hi

i have a attribute named rug_size which i created through Magento Attributes, in the menu. It is a text field, the backend_type is varchar (i looked it up in the eav_attribute)

I’m storing info representing fractional numbers. When i order by this attribute, the data get’s ordered as a string, so:
{ 1, 11.1 , 2, 4, ... }.

I would like to change the backed_type to decimal, so i get correct ordering for it, in the following order:
{1, 2, 4, 11.1, ... }

When i changed backend_type to decimal in the eav_attribute table, the attribute value is not saved when saving the product. :-(

Aftter looking into the database structure, i realized there is a table named catalog_product_entity_varchar, in which the values for my new attributes are stored. So, by simple logic, the values should be positioned in the table corresponding the datatype, consequently in catalog_product_entity_decimal.

Question:
What should i do to make the attribute save itself in the the table catalog_product_entity_decimal instead of catalog_product_entity_varchar?

 
Magento Community Magento Community
Magento Community
Magento Community
 
deXXmd
Jr. Member
 
Total Posts:  24
Joined:  2009-04-15
 

OK, i solved it by myself smile

If you want to change the backend_type of an attribute:

1.  find it first in the table called eav_attribute, there are some predeffined values that you can set = {static, datetime, decimal, int, text, varchar}, in my case i want to set rug_size from varchar to decimal.
2.  go to the table called catalog_product_entity_XXX (XXX - the initial backend_type, in my case this was varchar). You will find in this table N records that have attribute_id = id of the the attribute that you have in the eav_attribute table. (N - the number of products having this attribute in their attribute_set)
3. go to the table catalog_product_entity_YYY (YYY - the new backend_type that you want to have for your attribute, in my case it was atalog_product_entity_decimal)

With all this done, all the sortings over this attribute work normally, as with numbers, not just strings.
Hope it helps smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagePsycho
Moderator
 
Avatar
Total Posts:  1702
Joined:  2009-06-23
 

You can refer to the following article for the purpose;
How to convert varchar type attribute to price type in magento?

Cheers!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top