Sometimes, we need to change the input type of attributes in Magento. Magento by default doesn't allow to change the input type from backend simply. We need to do this programmatically.
Here is a code to change the input type from dropdown to text.
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$iProductEntityTypeId = Mage::getModel('catalog/product')->getResource()->getTypeId();
$idAttributeOldSelect = $installer->getAttributeId($iProductEntityTypeId, 'manufacturer');
$installer->updateAttribute($iProductEntityTypeId, $idAttributeOldSelect, array(
'frontend_input' => 'text'
));
$installer->endSetup();
Finally, we need to remove the old values or they will conflict with the new setup.
DELETE FROM catalog_product_entity_int
WHERE entity_type_id = 4 and attribute_id = YOUR_ATTRIBUTE_ID_HERE;
Cheers!!
Here is a code to change the input type from dropdown to text.
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$iProductEntityTypeId = Mage::getModel('catalog/product')->getResource()->getTypeId();
$idAttributeOldSelect = $installer->getAttributeId($iProductEntityTypeId, 'manufacturer');
$installer->updateAttribute($iProductEntityTypeId, $idAttributeOldSelect, array(
'frontend_input' => 'text'
));
$installer->endSetup();
Finally, we need to remove the old values or they will conflict with the new setup.
DELETE FROM catalog_product_entity_int
WHERE entity_type_id = 4 and attribute_id = YOUR_ATTRIBUTE_ID_HERE;
Cheers!!
Comments
Post a Comment