Home » Magento7 January 2010

Magento: How to get controller, module, action and router name?

You can easily get controller name, action name, router name and module name in any template file or class file.


$this->getRequest() can be used in template (phtml) files.

Here is the code:


Here is the code:

The above functions (getControllerName, getActionName, getRouteName, getModuleName) are present in the class Mage_Core_Model_Url.

You can explore all requests with print_r.

Hope this helps. Thanks.


Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • Thanks for your answer. Y are very good friend. How do you do.

  • Tobias Hinz

    very nice, thx 

  • Vishal Lakhani

    Thanx…. Great info

  • Sankarsphp

    the above code works, but when I go to other page from home still it through it is home page. After clear cache it gives the correct page. How to get current page in that case?

  • Gats


  • praful

    How we print the the current module name with it’s package name?

    like module shows “catalog” its become a “Mage_Catalog”

  • Mage::app()->getRequest()->getControllerModule();

  • Pranav

    Same is with me, have you found solution???

  • The same for me in Magento 1.9.2, so quite fresh install.. Actually no solution. It is being cached.

  • Pranav

    I have disabled Block HTML cache for now. it’s working.