答案 0 :(得分:0)
通过设置脚本
向订单商品实体添加新属性$install = new Mage_Sales_Model_Resource_Setup('core_setup');
$options = array(
'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
'visible' => true,
'required' => false
);
$install->addAttribute('quote_item', 'custom_product_description', $options);
$install->addAttribute('order_item', 'custom_product_description', $options);
$install->endSetup();
在config.xml中添加属性
<sales>
<quote>
<item>
<product_attributes>
<custom_product_description />
</product_attributes>
</item>
</quote>
</sales>
<sales_quote_item_set_product>
<observers>
<yournamespace_customattribute>
<class>yournamespace_customattribute/observer</class>
<method>salesQuoteItemSetCustomAttribute</method>
</yournamespace_customattribute>
</observers>
</sales_quote_item_set_product>
public function salesQuoteItemSetCustomAttribute($observer)
{
$quoteItem = $observer->getQuoteItem();
$product = $observer->getProduct();
$quoteItem->setCustomProductDescription($product->getCustomProductDescription());
}
<fieldsets>
<sales_convert_quote_item>
<custom_product_description>
<to_order_item>*</to_order_item>
</custom_product_description>
</sales_convert_quote_item>
<sales_convert_order_item>
<custom_product_description>
<to_quote_item>*</to_quote_item>
</custom_product_description>
</sales_convert_order_item>
</fieldsets>