整个网站都有“退出”链接。如果我们点击Logout,它将重定向到此页面。
http://sitename/customer/account/logoutSuccess/
但在一些phtml页面中,例如,在下页
中http://sitename.com/marketplace/marketplaceaccount/myproductslist/
如果我们点击“退出”,它应该注销但重定向到以下网址:
http://sitename.com/marketplace
在谷歌我找到重定向整个网站。但我只需要一些页面。
我使用以下代码:Accountcontroller.php
require_once 'Mage/Customer/controllers/AccountController.php';
class Webkul_Marketplace_AccountController extends Mage_Customer_AccountController{
public function marketlogoutAction()
{
$this->_getSession()->logout()
->renewSession();
//add your code here
$this->_redirect('marketplace');
echo "something";
exit();
}
public function logoutAction()
{
$this->_getSession()->logout()
->renewSession();
$this->_redirect('*/*/logoutSuccess');
}
Data.php [app / code / local / Mage / Customer / Helper]
public function getLogoutUrl()
{
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
if (strpos($currentUrl,'marketplaceaccount') !== false) {
return $this->_getUrl('marketplace');
}else
{
return $this->_getUrl('customer/account/logout');
}
}
但是当我从某些phtml页面退出时,它会重定向到我需要的页面,但是没有注销。
答案 0 :(得分:1)
将助手(Data.php)功能更改为:
return $this->_getUrl('customer/account/marketlogout');
而不是
$this->_getUrl('marketplace')
否则,它只是将您重定向到市场网址
答案 1 :(得分:0)
使用此代码.. data.php
public function getLogoutUrl()
{
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
if (strpos($currentUrl,'marketplaceaccount') !== false) {
return $this->_getUrl('marketplace/account/marketlogout');
} else if (strpos($currentUrl,'mpshippingmanager') !== false) {
return $this->_getUrl('marketplace/account/mpshippingmanagerlogout');
} else if (strpos($currentUrl,'mpmassuploadaddons') !== false) {
return $this->_getUrl('marketplace/account/mpmassuploadaddonslogout');
}else if (strpos($currentUrl,'mpassignproduct') !== false) {
return $this->_getUrl('marketplace/account/mpassignproductlogout');
}else
{
return $this->_getUrl('customer/account/logout');
}
}
这是行动。在Accountcontroller中添加一个函数
public function mpmassuploadaddonslogoutAction()
{
Mage::getSingleton('customer/session')->logout();
//add your code here
$this->_redirect('mpmassuploadaddons');
}
public function mpmassuploadaddonslogoutAction()
{
Mage::getSingleton('customer/session')->logout();
//add your code here
$this->_redirect('mpmassuploadaddons');
}
public function mpassignproductlogoutAction()
{
Mage::getSingleton('customer/session')->logout();
//add your code here
$this->_redirect('mpassignproduct');
} public function marketlogoutAction()
{
Mage::getSingleton('customer/session')->logout();
//add your code here
$this->_redirect('marketplace');
}