3

Is it possible to rewrite a controller in a community module that is already rewriting a core controller?

I have the syntax correct as it is working in other rewrites but in this specific case the rewrite is not working.

There is a community module rewriting the cart controller and i want to rewrite the community modules cart controller.

It would be like this:

My Controller -> Community Modules cart controller -> Mage Cart controller
8

This may depend on how the extension is overriding the controller but here goes. You need to add in your module's config.xml file, this as a child of the <config> node.

<frontend>
    <routers>
        <checkout>
            <args>
                <modules>
                    <Your_ModuleNameHere before="Community_ModuleNameHere">Your_ModuleNameHere</Your_ModuleNameHere>
                </modules>
            </args>
        </checkout>
    </routers>
</frontend>

If the community module overrides the cart controller in the same way as described above then it works. If it uses the 'old method' with <from> and <to> tags then it won't work.
(and I have no idea on how to override that).

[EDIT]
Make sure that your controller is also named CartController and it's located in Namespace/Module/controllers/CartController.php. Also you might want to make your local module depend on the community module but I don't think this is mandatory. Also make your controller class extend the community module controller.

  • this is precicely what is happening but it will not work. How would one normally debug this? – Marty Wallace Sep 4 '13 at 12:53
  • @MartyWallace. I've just tested and it works. But see my update to the answer. – Marius Sep 4 '13 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.