且构网

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

Magento - 向 sales_flat_quote_item 和 sales_flat_order_item 添加新列

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

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