Magento adminhtml getUrl

$this->getUrl($route) can be used in templates to generate an absolute URL based on route, but it only works for frontend URLs. As for adminhtml URLs, unless you say No to “Add Secret Key to URLs” in System >> Configuration >> Admin, a valid adminhtml URL should have a secret key.

$this->getUrl($route, $params) can take ‘_current’ as one of parameters, but it only attaches current URL’s parameters. Adminhtml URL secret keys vary with controller and action names. So how to get unique secret key by controller and action names? Easy peasy, just use:

Mage::getSingleton('adminhtml/url')->getSecretKey($controllerName, $actionName);

How to get URL to adminhtml route (attach the secret key automatically if it is enabled)? Just use:


Leave a comment

Your email address will not be published. Required fields are marked *