Override Controllers in Magento

May 30, 2011 16:41

Sometimes you may have to override the core controllers to add some specific functions, don’t know how to override them? Just simply follow below:

If you want to override the some controllers in adminhtml module for admin, add the following XML to your own module’s config.xml:

<config>
    ....
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <my_Module before="Mage_Adminhtml">MyNameSpace_MyModule_Adminhtml</my_Module>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
    ...
</config>

If you want to override the some controllers in checkout module for frontend, add the following XML to your own module’s config.xml:

<config>
    ...
    <frontend>
        <routers>
            <checkout>
                <args>
                    <modules>
                        <module before="Mage_Checkout">MyNameSpace_MyModule_Checkout</module>
                    </modules>
                </args>
            </checkout>
        </routers>
    </frontend>
    ...
</config>

That is, easy?

Happy Magento’ing ~

Share

Comments are closed.