1
我正在使用Magento 1.9。*,並且我想在用戶登錄成功登錄後重定向上一頁。Magento登錄後如何在上一頁重定向
我正在使用Magento 1.9。*,並且我想在用戶登錄成功登錄後重定向上一頁。Magento登錄後如何在上一頁重定向
我找到了一個解決方案,
對於按照以下步驟 打開header.phtml
在文件的頂部
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);
}
}
覆蓋/app/code/core/Mage/Customer/controllers
將此代碼添加到您的本地或自定義模塊,並添加此功能
protected function _loginPostRedirect()
{
$session = $this->_getSession();
$backUrlcustom=Mage::getSingleton('core/session')
->getLoginBackUrl();
if(isset($backUrlcustom) && $backUrlcustom !=""){
$session->setBeforeAuthUrl($backUrlcustom);
}
$this->_redirectUrl($session->getBeforeAuthUrl(true));
}
這對我很有用。
你有什麼試過?你有沒有遇到任何錯誤?你有什麼可以分享的嗎?我們無法幫助您基於「我要這個」類型的聲明 –
嗨@m_callens,我嘗試在主頁上重定向,但我需要重定向最後一頁,例如用戶在購物車頁面上並打開登錄頁面,然後登錄那麼它會重定向購物車頁面,而不是我的帳戶頁面。任何想法我能做什麼?我可以用會話管理嗎?如果您瞭解並且您有任何想法,請告訴我。 – Dhrumin