【问题标题】:Magento Module not loadingMagento 模块未加载
【发布时间】:2014-09-21 01:17:05
【问题描述】:

这是我的 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 后端显示.. 但代码不执行

有什么想法???我错过了什么吗??

【问题讨论】:

    标签: xml class magento overriding checkout


    【解决方案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
    

    【讨论】:

    • 谢谢...我做到了...但我的自定义函数仍然没有覆盖父类函数...有什么帮助吗?有什么想法吗?
    【解决方案2】:

    在文件夹 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');
    }
    

    【讨论】:

      【解决方案3】:

      为您的模型设置别名时出错。 尝试改变

      <zee_checkout>Zee_Checkout_Model</zee_checkout>
      

      <zee_checkout><class>Zee_Checkout_Model</class></zee_checkout>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-01-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-18
        • 1970-01-01
        相关资源
        最近更新 更多