Magento – How to Update Order Attribute

attributesmoduleorderssales-order

I was able to successfully add new order field through an install script:

$installer->addAttribute('order', 'is_local', array('type'=>Varien_Db_Ddl_Table::TYPE_SMALLINT, 'default'=>1));

However, I could not update the "default" property of it, let's say default=>0. One suggested to use updateAttribute() https://stackoverflow.com/questions/10420199/magento-module-setup-change-product-attribute-to-not-required but it doesn't work in order table.

Thank you.

Best Answer

Hi you can do this by updateAttribute() function

Create upgrade installer and on the upgrade file update field by updateAttribute() function.

Here

$installer = $this;
/* @var $installer Mage_Sales_Model_Mysql4_Setup */

$installer->startSetup();
$installer->updateAttribute('order', 'is_local',  array('default'=>0));
$installer->endSetup();

format:

$params=array()
$installer->updateAttribute(EntityTypeId,attribute_code',$params );

Till now ,i cannot find the where the issue But currently, i give u an alternative solution:

$installer = $this;
/* @var $installer Mage_Sales_Model_Mysql4_Setup */

$installer->startSetup();
$installer->run("ALTER TABLE  {$this->getTable('sales_flat_order')} CHANGE `is_local` `is_local` SMALLINT(6) NULL DEFAULT '0' COMMENT 'Is Local'");
$installer->endSetup();
Related Topic