As you know magento table structure is been built upon EAV (Entity Attribute Value) structure. Magento uses EAV to add more number of fields to table dynamically. Just to get one single record, Magento joins 4-5 tables to get data in EAV. So juts to convert one filed type to another you have to edit more number of tables as well and take their value as well which is not a good idea and can’t be managed easily. So lets what EAV is an how it works.
Lets take a little look about EAV so that you will understand better and can understand how to convert attribute type.

Magento Convert Attribute Type from price type to text type and vice versa and change all other attribute type another type
Magento Convert Attribute Type

EAV(Entity Attribute Value ):

EAV is a technique which allows you to add unlimited columns to your table dynamically. I mean the fields which is represented in ‘column’ way in a regular table, is represented in a ‘row’ (records) way in EAV table.

Entity:

Entity represent magento data item such as product, categories, customer, orders.Each entity will have its own record in database.

Attribute:

Attribute represent magento data item which belongs to entity. for example product entity has attribute such as price, name, status etc.

Value:

Value is just the value of an attribute that linked to.

So in the table table structure way one table hold attribute values called eav_attribute and 5-6 tables which holds entity and data in fully normalized form which will be different for different datatype like

  • For integer value : eav_entity_int
  • For Varchar value : eav_entity_varchar
  • For Datetime values : eav_entity_datetime
  • For Decimal/float values : eav_entity_decimal
  • For holding text (mysql Text type) values : eav_entity_text.

So let come back to our conversion for convert attribute type in magento
Here I have a custom script called “AttributeTypeConversion” and will work for text type to price and vice versa.In this script you can also convert more number attribute in a single time.No need to go for database table and to change manually . You will only also need to enter the attribute type and attribute code then submit and finally you will be getting the number records which was changed and make sure you will do this in development server not production server and also take whole database backup to avoid damage of database table.
Just download the AttributeTypeConversion.php file from AttributeTypeConversion or from last of article and place that php file in magento root directory and run in browser by www.yourdomain.com/AttributeTypeConversion.php

Here is the article to know How to import export sql file from command line.

Download magento convert attribute type file from AttributeTypeConversion

Thanks for visiting the article magento convert attribute type.

magento convert attribute type
Tagged on:                 

One thought on “magento convert attribute type

  • November 16, 2016 at 12:27 pm
    Permalink

    Thanks Jyoti this artical is very helpfull for me.
    thanks once again

    Reply

Leave a Reply

Your email address will not be published.