Tuesday, July 7, 2009

Redirection of URL

Mostly, this customization can be used in the case, in which user is on any page of site & after login, User need to redirect to that particular page.

Steps for this customization,

Step1 :
Go to the controller of every page.
For core module, app/code/core/Mage/moduleName/controllers/controllerName.php,
i.e. app/code/core/Mage/Catalog/controllers/ProductController.php.
For custom (newly created) module,
i.e. app/code/local/Mage/Contest/controllers/IndexController.php

Step2 :
In controller file every action function , actionNameAction(), i.e. indexAction(), detailAction(), postAction() etc., need to add following line.

Mage::getSingleton('customer/session')->setBeforeAuthUrl($this->getRequest()- >getRequestUri());

1 comment:

  1. For some reason the $session->setBeforeAuthUrl() call is not working on my action figure Magento install. It keeps on redirectind the logged in user to the mage control panel, not to the assigned url. Any ideas?

    ReplyDelete