【问题标题】:magento Change logout url link for some phtml pagesmagento 更改某些 phtml 页面的注销 url 链接
【发布时间】:2016-03-04 23:22:58
【问题描述】:

整个网站都有“注销”链接。如果我们点击注销,它会重定向到这个页面。

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 页面注销时,它会重定向到我需要的页面,但它没有注销。

【问题讨论】:

    标签: php magento


    【解决方案1】:

    将你的助手(Data.php)函数更改为:

    return $this->_getUrl('customer/account/marketlogout');

    而不是
    $this->_getUrl('marketplace')

    否则它只会将您重定向到市场网址

    【讨论】:

    • 我用过这个:return $this->_getUrl('customer/account/marketplace');但仍然没有退出
    • 它应该重定向到市场网址。这是我需要的,同时它也应该注销。但这没有发生
    • 我编辑了我的答案,应该是客户/帐户/市场退出
    • 我使用了这个:return $this->_getUrl('customer/account/marketlogout');但结果还是一样。
    • 嗯它应该可以工作,我注意到在另一个答案中您正在添加回显并退出,请确保您在调用 $this->_getSession()->logout() ->renewSession 之前没有退出();
    【解决方案2】:

    使用此代码.. 数据.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'); 
    
    } 
    

    【讨论】:

    • 我在 Accountcontroller.php 中添加了这个,但它不起作用。
    • 如果我删除助手 [Data.php] 文件,它将注销,但不会重定向到“市场”。
    • 注销成功了吗
    • 不,现在如果我从站点上的任何位置单击注销,而不是它的 echo "something" 。但是如果我从市场页面注销,它不会注销,而是像以前一样重定向到市场页面
    • 这正在工作:"return $this->_getUrl('customer/account/marketlogout');"但是我需要为其他扩展做什么?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-20
    • 2013-11-12
    相关资源
    最近更新 更多