Problems Overriding Magento Community Module Controller

前端 未结 2 1913
执笔经年
执笔经年 2021-01-17 04:48

First of all, the Answer here is very helpful: Overriding a Magento Controller in community extention

However, despite passing both of the \"tests\" mentioned in the

相关标签:
2条回答
  • 2021-01-17 04:59

    Just change

    <company_onepagecheckout before="IWD_OnepageCheckout">Company_OnepageCheckout</company_onepagecheckout> 
    

    to

    <Company_OnepageCheckout before="IWD_OnepageCheckout">Company_OnepageCheckout</Company_OnepageCheckout>
    

    If it is not working then used

    <global>
            <!-- This rewrite rule could be added to the database instead -->
            <rewrite>
                <!-- This is an identifier for your rewrite that should be unique -->
                <!-- THIS IS THE CLASSNAME IN YOUR OWN CONTROLLER -->
                <mynamespace_mymodule_onepage_iwd>
                    <from><![CDATA[#^/onepagecheckout/index/#]]></from>
                    <!--
                        - mymodule matches the router frontname below
                        - checkout_cart matches the path to your controller
    
                        Considering the router below, "/mymodule/checkout_car/" will be
                        "translated" to "/MyNameSpace/MyModule/controllers/Checkout/CartController.php" (?)
                    -->
                    <to>/comonepagecheckout/index/</to>
                </mynamespace_mymodule_onepage_iwd>
            </rewrite>
        </global>
    <frontend>
            <routers>
                <comonepagecheckout>
                    <!-- should be set to "admin" when overloading admin stuff (?) -->
                    <use>standard</use>
                    <args>
                        <module>Company_OnepageCheckout</module>
                        <!-- This is used when "catching" the rewrite above -->
                        <frontName>comonepagecheckout</frontName>
                    </args>
                </comonepagecheckout>
            </routers>
        </frontend>
    

    See more at

    0 讨论(0)
  • 2021-01-17 05:03

    Your best bet is to drop some debugging code into the standard router (temporarily, of course).

    #File: app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
    protected function _validateControllerClassName($realModule, $controller)
    {
        $controllerFileName = $this->getControllerFileName($realModule, $controller);
        if (!$this->validateControllerFileName($controllerFileName)) {
            return false;
        }
    
        $controllerClassName = $this->getControllerClassName($realModule, $controller);
        if (!$controllerClassName) {
            return false;
        }
    
        // include controller file if needed
        if (!$this->_includeControllerClass($controllerFileName, $controllerClassName)) {
            return false;
        }
    
        return $controllerClassName;
    }
    

    Each return false is an instance where the router considers a configured controller and rejects it based on an improper name, not being able to find or include the file, etc.

    0 讨论(0)
提交回复
热议问题