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 

1 Answer 1

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.

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.