我想将客户重定向到客户点击登录的页面,例如,如果客户在任何类别页面上并点击登录,则登录后他必须重定向到类别页面。
我在customer_login
事件的观察者中执行此代码但是当尝试在auth url之前获取时,我得到customer/account/loginPost
而不是类别url。
我使用的代码是:
$session = Mage::getSingleton( 'customer/session' );
Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::getUrl('*/*/*'))
但是当输出为
时,这并没有重定向到任何地方 [before_auth_url] => /customer/account/loginPost/
[after_auth_url] =>/customer/account/loginPost/
答案 0 :(得分:-1)
您可以从管理员端进行配置。
登录Magento管理员端并更改系统配置
的 System > Configuration > Customer configuration > Login options > Redirect Customer to Account Dashboard after Logging in > No
即可。
如果选择“否”,客户将留在当前页面上。
答案 1 :(得分:-1)
你好朋友,你可以这样做。
应用程序/代码/核心/法师/客户/控制器/ AccountController.php
//$session->setBeforeAuthUrl($this->_getHelper('customer')->getAccountUrl());
$session->setBeforeAuthUrl(Mage::getBaseUrl().'your_url');
答案 2 :(得分:-1)
我自己得到了这个,希望这对别人有帮助。
在登录前创建观察者并捕获网址。 controller_action_predispatch_customer_account_login
<controller_action_predispatch_customer_account_login>
<observers>
<ash_getref>
<class>ash_getref/observer_customer</class>
<method>getReferrerUrl</method>
</ash_getref>
</observers>
</controller_action_predispatch_customer_account_login>
并在观察者文件中的自定义会话变量中保存引用值url。
public function getReferrerUrl(Varien_Event_Observer $observer){
Mage::getSingleton('core/session')->setReferrerUrl(Mage::helper('core/http')->getHttpReferer() ? Mage::helper('core/http')->getHttpReferer() : Mage::getUrl());
}
然后为登录后事件创建观察者,即customer_login
。
<customer_login>
<observers>
<ash_getref>
<class>ash_getref/observer_customer</class>
<method>customerLogin</method>
</ash_getref>
</observers>
</customer_login>
然后在观察者中重定向。
public function customerLogin(){
Mage::app()->getResponse()->setRedirect(Mage::getSingleton('core/session')->getReferrerUrl());
Mage::app()->getResponse()->sendResponse();
exit;
}