To change product attribute type from dropdown to multiselect in magento

Posted: December 6, 2012 in Magento, Version 1.3.*, Version 1.4.*, Version 1.6.*

Hello Guys,

I want to share you how to change product attribute input type from dropdown to multiselect in magento.

Below code will change input type of attribute ‘grade’ & remove value of attribute already exist in products. You can create file and add below code, Don’t forget to replace ‘grade’ with your attribute code.

define('MAGENTO_ROOT', getcwd());

$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once $mageFilename;

$installer = new Mage_Eav_Model_Entity_Setup('core_setup');

$entityTypeId = $installer->getEntityTypeId('catalog_product');

$idAttributeOldSelect = $installer->getAttribute($entityTypeId, 'grade', 'attribute_id');
$installer->updateAttribute($entityTypeId,$idAttributeOldSelect, 'frontend_input','multiselect');
$installer->updateAttribute($entityTypeId,$idAttributeOldSelect, 'backend_type','varchar');
$installer->updateAttribute($entityTypeId,$idAttributeOldSelect, 'backend_model','eav/entity_attribute_backend_array');
$installer->updateAttribute($entityTypeId,$idAttributeOldSelect, 'source_model','');
$installer->run("DELETE FROM `catalog_product_entity_int` where `attribute_id` = {$idAttributeOldSelect}");


I hope above code will help you.

Thank You,
Bijal Bhavsar 🙂

  1. Heya i’m for the first time here. I came across this board and I find It really useful & it helped me out a lot. I hope to provide one thing back and aid others like you aided me.

  2. dennisme2 says:

    Thanks man,
    this worked straight off the bat in 1.7.02 CE.

  3. Vasily says:

    Thanks, works like a charm

  4. Andreas says:

    how can i start the .php file and where on the server .. thx

  5. ZC says:

    Very Good job . Thank you very much .

    i try run on magento 1.9.2.

    it can change multiselect, but can not keep “Attribute value”

    such as: before is Iphone “8G” in dropdown. change to multiselect , not select “8G” , it is empty.

    Thank you very much.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s