Magento - Adding a new column to sales_flat_quote_item and sales_flat_order_item

梦想与她 提交于 2019-11-28 05:09:14
  1. Create a new module with own setup class extended from Mage_Sales_Model_Mysql4_Setup or just use it as module setup class in config.xml:

     <global>
         <resources>
             <your_module_setup>
                  <setup>
                      <module>Your_Module</module>
                      <class>Mage_Sales_Model_Mysql4_Setup</class>
                  </setup>
             </your_module_setup>
         </resources>
     </global>
    
  2. Use addAttribute($entity, $attributeCode, $options) method inside of your setup script, it will automatically add a new column to sales_flat_order tale. The same for other entites.

    $installer = $this;
    $installer->startSetup();
    $installer->addAttribute(
        'order', 
        'your_attribute_code', 
        array(
            'type' => 'int', /* varchar, text, decimal, datetime */,
            'grid' => false /* or true if you wan't use this attribute on orders grid page */
        )
    );
    $installer->endSetup();
    

important thing to know when adding attributes to orders: you need to add the same attributes to quotes, too (at least in my case this solved all problems)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!