Redirection after login in Magento 1.9 without extension

Hello Reader,
Happy New Year!

This tutorial explains how to redirect to other page after login in Magento 1.9 without extension. I know in Magento marketplace there are lots of extensions available. But we don’t want to use such kinds of extension. Just follow my step are as follow :

Please download observer extension.

In observer extension, there are two folders. 1) etc 2) Model
1) In the etc folder, there is only one config.xml file and in that file, all the observer event define.
2) In Model folder, there is one file called Observer.php and in that file, we have to define our logic.

After login event called  controller_action_postdispatch_customer_account_loginPost
Eg. config.xml

<controller_action_postdispatch_customer_account_loginPost>
<observers>
<ybizz_pricechange_observer>
<class>ybizz_pricechange/observer</class>
<method>homeRedirect</method>
</ybizz_pricechange_observer>
</observers>
</controller_action_postdispatch_customer_account_loginPost>

So, we need to make all the logic regarding redirect in this event.
In this example, I’ve checked store name just for understanding but you can use as per your need.

Eg. Observer.php

public function homeRedirect(Varien_Event_Observer $observer) {
$code = Mage::app()->getStore()->getCode();
if ($code == “wholesale”) {// check store name
Mage::app()->getResponse()->setRedirect(Mage::getUrl());
}
}

Download Demo

I hope you understand this tutorial. If you have any questions or confusion then please comment it..


Comments

Leave a Reply

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