且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Magento-在sales_flat_quote_item和sales_flat_order_item中添加新列

更新时间:2023-11-29 23:16:58

  1. 使用自Mage_Sales_Model_Mysql4_Setup扩展的自己的安装程序类创建新模块,或仅将其用作config.xml中的模块安装程序类:

  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>

在安装脚本中使用

  • 使用addAttribute($entity, $attributeCode, $options)方法,它将自动向sales_flat_order故事中添加新列.其他实体也一样.

  • 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();