简体   繁体   English

如何将产品特定的属性列添加到sales_flat_order_item表?

[英]How to add product specific attribute column to sales_flat_order_item table?

In admin panel I have created a product attribute as ' merchant '. 在管理面板中,我已将product attribute创建为“ merchant ”。 I want to add a new column for merchant in sales_flat_order_item table. 我想在sales_flat_order_item表中为merchant添加新列。 The new column should be filled with the attribute name. 新列应填充属性名称。 How can I do this without using an event observer method? 不使用事件观察器方法怎么办? Any help will be appreciated. 任何帮助将不胜感激。 (I'm using magento CE 1.7 ) (我正在使用magento CE 1.7)

First of all, you need to add the new column to sales_flat_quote item, and sales_flat_order_item. 首先,您需要将新列添加到sales_flat_quote项目和sales_flat_order_item。 the best explanation is here: http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-6-magento-setup-resources 最好的解释在这里: http : //www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-6-magento-setup-resources

Your setup resource have to looks something like this: 您的设置资源必须看起来像这样:

$installer = $this;
$installer->startSetup();
$installer->getConnection()
        ->addColumn(
            $installer->getTable('sales/quote_item'), 'merchant', 'VARCHAR(20) NOT NULL');
$installer->getConnection()
          ->addColumn(
            $installer->getTable('sales/order_item'), 'merchant', 'VARCHAR(20) NOT NULL')

In order to pass the data from the quote_item to order_item you need in to specify in your config.xml something like this: * 为了将数据从quote_item传递到order_item,您需要在config.xml中指定类似以下内容:*

And then, in order to save the data in quote item, you need an observer, I suggest you to read this: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method The event you are looking for is In the observer method you'll have to do something like this 然后,为了将数据保存在报价项目中,您需要一个观察者,我建议您阅读以下内容: http : //www.magentocommerce.com/wiki/5_-__modules_and_development/0_-__module_development_in_magento/customizing_magento_using_event-observer_method您要寻找的是在观察者方法中,您必须执行以下操作

class MyNamespace_Mymodule_Model_Observer
{
    public function saveTheMerchant($observer)
    {
        $item = $observer->getEvent()->getQuoteItem();
        $product = $item->getProduct();
        $item->setMerchant($product->getMethant());
        $item->save();
    }
}

Greetings. 问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有sales_flat_order_item的product_options的_prepareCollection - _prepareCollection with product_options of sales_flat_order_item Magento-更新sales_flat_order_item表中发票的数量 - Magento - update the qty invoiced in sales_flat_order_item table Magento - 向sales_flat_quote_item和sales_flat_order_item添加新列 - Magento - Adding a new column to sales_flat_quote_item and sales_flat_order_item 从magento中的自定义模块在sales_flat_order_item表中添加新字段 - Adding new field in sales_flat_order_item table from custom module in magento 在sales_flat_quote和sales_flat_order_item表中添加额外信息 - Adding extra information in sales_flat_quote and sales_flat_order_item tables **更新**如何在表sales_flat_quote_item中创建新列并使用$ cart-> addProduct添加数据 - **update** How i can create new column in table sales_flat_quote_item and add data with $cart->addProduct 在产品环境中的magento中向销售/订单模型添加属性 - add a attribute to sales/order model in magento in product environment 在magento中完成订单后,更新sales_flat_order表的自定义列 - Update a custom column of sales_flat_order table after order complete in magento Magento-将媒体库属性添加到产品平面表 - Magento - add media gallery attribute to product flat table 如何在magento 1.8.1中添加产品图像销售订单网格? - How to add product image sales order grid in magento 1.8.1?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM