我创建了一个模块,用于在sales_flat_order自定义字段中存储自定义结帐字段值。提交已创建。但是在下订单后它没有存储的价值。我是Magento的新人。
app/code/local/Iclp/Orderattribute/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Iclp_Orderattribute>
<version>0.1.0</version>
</Iclp_Orderattribute>
</modules>
<global>
<helpers>
<orderattribute>
<class>Iclp_Orderattribute_Helper</class>
</orderattribute>
</helpers>
<models>
<orderattribute>
<class>Iclp_Orderattribute_Model</class>
<resourceModel>orderattribute_mysql4</resourceModel>
</orderattribute>
</models>
<resources>
<salesattribute1422420996_setup>
<setup>
<module>Iclp_Orderattribute</module>
<class>Mage_Sales_Model_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</salesattribute1422420996_setup>
<salesattribute1422420996_write>
<connection>
<use>core_write</use>
</connection>
</salesattribute1422420996_write>
<salesattribute1422420996_read>
<connection>
<use>core_read</use>
</connection>
</salesattribute1422420996_read>
</resources>
<events>
<checkout_type_onepage_save_order> <!-- identifier of the event we want to catch -->
<observers>
<checkout_type_onepage_save_order_handler> <!-- identifier of the event handler -->
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
<class>orderattribute/observer</class> <!-- observers class alias -->
<method>getorderattribute</method> <!-- observer's method to be called -->
<args></args> <!-- additional arguments passed to observer -->
</checkout_type_onepage_save_order_handler>
</observers>
</checkout_type_onepage_save_order>
</events>
</global>
</config>
app/code/local/Iclp/Orderattribute/Model/Observer.php
<?php
class Iclp_Orderattribute_Model_Observer
{
public function getorderattribute(Varien_Event_Observer $observer)
{
$event = $observer->getEvent();
$order = $event->getOrder();
$fieldVal = Mage::app()->getFrontController()->getRequest()->getParams();
$order->setOrder_Attribute($fieldVal['order_attribute']);
//echo "<script>alert('fff');</script>" ;
}
}
sql/salesattribute1422420996_setup/mysql4-install-0.1.0.php
<?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute("order", "order_attribute", array("type"=>"varchar"));
$installer->endSetup();
答案 0 :(得分:0)
我认为您的模块中存在配置错误。
<global>
...
<fieldsets>
<sales_convert_quote>
<your_special_attribute>
<to_order>*</to_order>
</your_special_attribute>
</sales_convert_quote>
</fieldsets>
...
</global>
您是否已将新属性分配给qoute?
$installer->addAttribute("quote", "order_attribute", array("type"=>"varchar"));