如何在Magento中覆盖corefile(控制器文件)?

时间:2011-10-21 07:29:06

标签: magento

我必须在控制器文件中添加自定义功能。我没有更改核心文件,而是将此文件放在本地文件夹中(遵循相同的目录结构)并添加了我的自定义代码。但Magento仍在使用旧的控制器文件。如何调用这个新的控制器文件?

1 个答案:

答案 0 :(得分:1)

仅供参考,控制器覆盖无法通过复制粘贴app / code / local文件夹中的控制器文件,文件夹层次与Block / Helper / Model overriding不同。

要覆盖控制器,请遵循以下xml块:

<config>
    <frontend> [1]
        <routers>
            <checkout> [2]
                <args>
                    <modules>
                        <yourModule before="Mage_Checkout">Namespace_Module_Overwrite_Checkout</yourModule> [3]
                    </modules>
                </args>
            </checkout>
        </routers>
    </frontend>
</config>
Where,
[1] Depending on the controllers area "frontend“ or "admin“
[2] Router node of the module to be overridden (look it up in the config.xml of that module)
[3] The tag  can be anything, it must be unique within the  node.
Your_Module_Overwrite_Checkout (is mapped to directory)
Your/Module/controllers/Overwrite/Checkout/

Hope this helps.
Happy E-Commerce!!
相关问题