[英]Magento2, how to display and get the custom table columns of sales_order table in rest API orders detail?
[英]How can Add the text filed like custom price in sales->orders and store in database table Magento 1.9?
通过设置脚本向订单项实体添加新属性
$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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.