问题改写Magento社区模块控制器 [英] Problems Overriding Magento Community Module Controller

查看:154
本文介绍了问题改写Magento社区模块控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,这里的答案非常有帮助:在社区扩展中覆盖Magento控制器

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 answer there, I still have a module controller override that just refuses to work. Here is what I have:

\app\code\local\Company\OnepageCheckout\etc\config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Company_OnepageCheckout>
            <version>0.0.1</version> 
        </Company_OnepageCheckout>
    </modules>
    <frontend>
        <routers>
            <onepagecheckout>
                <args>
                    <modules>
                        <company_onepagecheckout before="IWD_OnepageCheckout">Company_OnepageCheckout</company_onepagecheckout>
                    </modules>
                </args>
            </onepagecheckout>
        </routers>
    </frontend>
</config>

\app\code\local\Company\OnepageCheckout\controllers \IndexController.php

<?php

require_once(Mage::getModuleDir('controllers','IWD_OnepageCheckout').DS.'IndexController.php');

class Company_OnepageCheckout_IndexController extends IWD_OnepageCheckout_IndexController
{
    function indexAction() {
        die('Hello world!');
    }
}

\app\etc\ modules\Company_OnepageCheckout.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Company_OnepageCheckout>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <IWD_OnepageCheckout />
            </depends>
        </Company_OnepageCheckout>
    </modules>
</config>

此模块用于覆盖位于 \app \ code\community\IWD\OnepageCheckout\ [...]

如本文顶部所述,我使用了其他问题中建议的Reflection类,并且可以在社区模块之前首先在数组中看到我的模块。但是,当我访问mysite.com/onepagecheckout时,我仍然看到社区模块,无法使用我的文件。

As mentioned at the top of this post, I've used the Reflection class as suggested in that other Question and can see my module first in the array ahead of the community module. However, when I visit mysite.com/onepagecheckout I still see the community module, and can't get it to use my file.

我的预感在这里

推荐答案

只需更改

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

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

如果不工作,则使用

<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>

查看更多

这篇关于问题改写Magento社区模块控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆