I have a file as follows:


and a uniquely defined action in that file:

public function sendfriendemailAction() ..

However the URL to post to that action is as follows:

<form action=<?php echo $this->getUrl('ajax/product/sendfriendemail');?>" .. >

The string in the form action doesn't even remotely compare to the path where the actual action method is found (and BTW it does work).

How does Magento figure out that that URL maps to that location? Thank you for insight on how Magento thinks.

2 Answers 2


'ajax/product/sendfriendemail' is not a core URL,
Most probably you have a module that contains this in the config.xml


Notice the <frontName>ajax</frontName>. That's the first part of the URL ajax/product/sendfriendemail.
Magento looks in the merged config for a node with frontName identical to the first part of the url and when it finds it it maps the rest of the url relative to that module.
So in the example above ajax corresponds to the module [Namespace]_[Module] so magento will try to match the rest of the url product/sendfriendemail to the controller ProductController from the module [Namespace]_[Module] and execute the method sendfriendemailAction.

This is just the main part.
There are exceptions. you can tell magento for the same key (ajax in this case) to look in multiple modules in a specific order and call the first valid method it finds in a valid controller.

For this, you have to define the routes for your module like this:

                    <[Namespace]_[Module] before="[Other]_[Module]">[Namespace]_[Module]</[Namespace]_[Module]>

This means that the module [Namespace]_[Module] will use the same frontName as the module [Other]_[Module]. If the rest of the url cannot be mapped to a controller and an action from [Namespace]_[Module] it will try to map it to a controller and action from the initial module [Other]_[Module]

  • By the way, you mention, not a core URL, how are you determining that and is there some resource listing core routing URLs? Jan 7, 2017 at 14:37

I'll answer this with an example.

In app/code/core/Mage/Catalog/etc/config.xml you can see the controllers defined in the <routers> tag like so:


This configuration is used to tell magento that when you go to /catalog that it should look for the controllers in the Mage_Catalog module.

catalog/product would then try and resolve Mage_Catalog_ProductController by doing something like.

Mage::getConfig()->getModuleDir('controllers', 'Mage_Catalog') . '/ProductController.php';

and doing something like catalog/product/view would look for a public function viewAction within the returned controller.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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