[英]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.