Get Free Audit

Request Routing (Magento Certified Developer Exam)

Dec 17, 2012

4246 Aleksander Tretjak

Request Routing (Magento Certified Developer Exam)

Route determination starts with the search for the current route compliance with the routes, determined in the system. The process begins here:

app/code/core/Mage/Core/Controller/Varien/Front.php


There are 4 routes defined in Magento by default:

Mage_Core_Controller_Varien_Router_Admin
Mage_Core_Controller_Varien_Router_Standard
Mage_Cms_Controller_Router
Mage_Core_Controller_Varien_Router_Default

As we know from Magento Front Controller Pattern article, $this->_routers variable contains all the defined routes. The searching will be thereby performed in this array. It will be carried out among all the routes and will stop at the first match found. If no matches are found, the route defined for 404 will be processed or the ‘Front controller reached 100 router match iterations’ message will be displayed:


Main steps of the routing process:

  • module determination
  • controller determination
  • action to perform detection
  • data for the current request detection

Let’s take a look at the routes initialization:


Administrative routes are being initialized first:

app/code/core/Mage/Core/Controller/Varien/Router/Admin.php


The route, administrative part is accessible at, is verified here. It is also checked if it is redefined or not. Considering Admin is the extension of Standard, the following is next executed:


All the routes defined in the configuration are picked and processed here, considering before and after events.  _modules and _routes arrays of modules and routes correspondingly for the current route type are also filled:

app/code/core/Mage/Core/Controller/Varien/Router/Standard.php


Next, this route object is added to the general routes list:

app/code/core/Mage/Core/Controller/Varien/Front.php


Standard routes are initialized the same way.

It can be demonstrated easier as follows:

Igor Dragun
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Igor


CMS (“static”) routes are added via controller_front_init_routers event next:

app/code/core/Mage/Cms/etc/config.xml


app/code/core/Mage/Cms/Controller/Router.php


After all, Default 404/no-route routes:


After routes initialization, searching for appropriate things is performed:


As Admin routes are an extension to Standard, we first look more closely at Standard. It’s primarily checked if the administrative interface is active:


Default route is defined next:


The current request goes next; it is taken to pieces:


For example, for the following path: catalog/category/view/id/10 we get:


First 3 elements are principal here; they indicate module, controller and action for the current request.

Next, the module is determined from its frontName:


The controller and the action for the current request are thereafter defined:


It’s also checked if the connection is safe and if the controller file exists:


Controller object is created next. It’s checked if the specified action exists in the controller:



It’s after all flagged that the route is processed. Module, controller and action are defined and action is performed for the current request.


Control returns to dispatch FrontController method, where “output” is defined for the current request.

Igor Dragun
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Igor

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *