如何覆盖Magento控制器? [英] How can I override a Magento controller?

查看:104
本文介绍了如何覆盖Magento控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用服务器端代码在结帐/购物车页面上检查优惠券代码的有效性.

I need to check the validity of a coupon code on the checkout/cart page with server-side code.

Magento已经附带了类似的支票.但是,我需要添加一个以查看用户是否连接:在Magento中扩展/覆盖该操作的最佳方法是什么?

Magento already ships with a similar check in place. However, I need to add one to see if a user is connected or not: what would be the best way to extend/override that action in Magento?

我知道我可以将控制器PHP文件复制到/app/code/local/文件夹树中,但是我想知道是否有更好的方法来做到这一点.

I know I can copy the controller PHP file to the /app/code/local/ folder tree, but I'm wondering whether there's a better way to do it.

推荐答案

除了修改core之外,其他任何事情都很好.这样,用config.xml创建一个带有controllers目录等的简单模块:

Anything besides modifying the core is good in my opinion. With that said create a simple module with a controllers directory and etc with config.xml:

<config>
    <frontend>
        <routers>
            <checkout>
                <args>
                    <modules>
                         <My_Module before="Mage_Checkout">My_Module_Checkout</My_Module>
                    </modules>
                </args>
            </checkout>
        </routers>
    </frontend>
</config>

有关如何扩展前端控制器的更多详细信息,请参见此处: http://prattski.com/2010/06/24 /magento-overriding-core-files-blocks-models-resources-controllers/

See here for more details on how to extend the frontend controller: http://prattski.com/2010/06/24/magento-overriding-core-files-blocks-models-resources-controllers/

这篇关于如何覆盖Magento控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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