这是我的config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<zee_Checkout>
<version>1.0</version>
</zee_Checkout>
</modules>
<global>
<models>
<zee_Checkout>zee_Checkout_Model</zee_Checkout>
<checkout>
<rewrite>
<type_onepage>zee_Checkout_Model_Type_Onepage</type_onepage>
</rewrite>
</checkout>
</models>
</global>
</config>
这是我的code/local/zee/Checkout/Model/Type/Onepage.php
class zee_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
{
public function saveOrder()
{
$this->validate();
$isNewCustomer = false;
switch ($this->getCheckoutMethod()) {
case self::METHOD_GUEST:
$this->_prepareGuestQuote();
break;
case self::METHOD_REGISTER:
$this->_prepareNewCustomerQuote();
$isNewCustomer = true;
break;
default:
$this->_prepareCustomerQuote();
break;
}
....
.....
Only this function needs to be Over-rided...so I wrote just this funciton, nothing else in this file except this function
}
}
问题是......这个函数没有加载...而是来自父/核心magento文件的saveOrder()执行......
模块已启用,其显示在Magento Backend中..但代码未执行
任何想法???我错过了什么吗?
答案 0 :(得分:1)
在config.xml中更改
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Zee_Checkout> <!-- zee should be Zee -->
<version>1.0</version>
</Zee_Checkout>
</modules>
<global>
<models>
<zee_checkout>zee_Checkout_Model</zee_checkout>
<checkout>
<rewrite>
<type_onepage>Zee_Checkout_Model_Type_Onepage</type_onepage>
</rewrite>
</checkout>
</models>
</global>
</config>
文件夹名称zee should be Zee
class zee_Checkout_Model_Type_Onepage
到
Zee_Checkout_Model_Type_Onepage
答案 1 :(得分:1)
在文件夹app / etc / modules
中设置Zee_Checkout.xml<?xml version="1.0"?>
<config>
<modules>
<Zee_Checkout>
<active>true</active>
<codePool>local</codePool>
</Zee_Checkout>
</modules>
</config>
在Zee / Checkout / etc / config.xml中设置config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Zee_Checkout>
<version>1.0</version>
</Zee_Checkout>
</modules>
<global>
<models>
<checkout>zee_Checkout_Model</checkout>
<checkout>
<rewrite>
<type_onepage>Zee_Checkout_Model_Type_Onepage</type_onepage>
</rewrite>
</checkout>
</models>
</global>
</config>
要检查文件是否正常,请在Zee \ Checkout \ Model \ Type \ Onepage.php
中的Onepage.php中添加日志public function __construct()
{
Mage::log('hellloss',null,'hello.log');
$this->_helper = Mage::helper('checkout');
$this->_customerEmailExistsMessage = Mage::helper('checkout')->__('There is already a customer registered using this email address. Please login using this email address or enter a different email address to register your account.');
$this->_checkoutSession = Mage::getSingleton('checkout/session');
$this->_customerSession = Mage::getSingleton('customer/session');
}
答案 2 :(得分:0)
为模型设置别名时出错。 尝试改变
<zee_checkout>Zee_Checkout_Model</zee_checkout>
要
<zee_checkout><class>Zee_Checkout_Model</class></zee_checkout>