Thứ Năm, 4 tháng 1, 2018

Magento: Redirect back to page after logged-in at Magento 1


Open header.phtml add this code at top of the file

if(!Mage::helper('customer')->isLoggedIn()) {

 $loginback=$this->helper('core/url')->getCurrentUrl();

 $check=strstr($loginback, 'customer/account/login');

 if(!strlen($check)){

 Mage::getSingleton('core/session')->setLoginBackUrl($loginback);

 }
}

Override app\code\core\Mage\Customer\controllers\AccountController.php to you local or custom module and add this function.

protected function _loginPostRedirect()
{
    $session = $this->_getSession();

    $backUrlcustom=Mage::getSingleton('core/session')
    ->getLoginBackUrl();

    if(isset($backUrlcustom) && $backUrlcustom !=""){
          $session->setBeforeAuthUrl($backUrlcustom);
    }
    $this->_redirectUrl($session->getBeforeAuthUrl(true));
}

Không có nhận xét nào:

Đăng nhận xét

About me

Recent

recentposts

Random

randomposts