I'm looking at a community extension called Ambassador_Affiliate, and it's doing something that I have not seen before. I'm not sure what it's doing, so I'd like to check with the community.

In config.xml, there is...

                    <Ambassador_Affiliate before="Mage_Customer">Ambassador_Affiliate</Ambassador_Affiliate>

In Ambassador/Affiliate/controllers/AffiliateController.php, there is…


class Ambassador_Affiliate_AffiliateController extends Mage_Core_Controller_Front_Action


It looks to me the Ambassador extension is adding a new controller, instead of rewriting, its own controller to the Mage_Customer module.

If it is so, why would you do this as opposed to just defining a entirely new controller under Ambassador_Affiliate (beside wanting to use the customer frontname of Mage_Customer)?

If it's not, what is it doing?


Magento checks all controllers whether the actionMethod exists, if this is the case, then it is executed.

The sorting order, can be defined via before and after

But using after makes no sense, if you ask me. If you want your controller to be executed, instead of the default one use before.

So if you want to kill all other actions, you can use your own frontName (with uppercase N!), if you only want to add one action, this is the right way.

  • How about Ambassador_Affiliate_AffiliateController? Why isn't it just being defined as a new controller in config.xml? May 29 '14 at 16:11
  • When you mean by a new controller a new route, like ambassador/controllername/actionname, then because the developer prefered to put it into the customer/* "namespace" May 29 '14 at 16:31
  • OK just to confirm, by defining it in the config.xml like above (<frontend><routers><customer><args><modules>) and not rewriting an existing controller), it will use customer/.../...? May 29 '14 at 16:36
  • Yes, when you use frontend/routers/... it will use customer. But what do you mean by rewrite exactly? There is no controller rewrite as for models, helpers and classes... May 29 '14 at 16:49
  • Typically when people use <frontend><routers>…, they end up creating a controller that extends an existing controller (i.e. "rewrite/override" by Abc_Xyz_Checkout_CartController extends Mage_Core_Checkout_CartController). I just meant that this particular extension is not doing that. May 29 '14 at 17:43

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.