Magento将referer param添加到getLoginPostUrl()

Rya*_*yan 3 php magento

我正在尝试创建一个表单,尽可能无缝地将登录集成到流程中.

我现在正在使用Mage::helper('customer')->getLoginPostUrl()登录表单,如果有更好的东西可以使用我都是耳朵,它可以工作,但它最终在用户仪表板上.

我查找了该函数并寻找它, if($this->_getRequest()->getParam(self::REFERER_QUERY_PARAM_NAME)){ 但我不知道如何以函数读取它的方式给它一个参数.

我注意到,如果我使用Mage::helper('customer')->getLoginUrl()它添加referer本身,所以我追踪它,并发现它如何将编码的referer添加到url并最终得到这个

<?php echo Mage::helper('customer')->getLoginPostUrl(); ?>referer/<?php echo Mage::helper('core')->urlEncode($this->getUrl("frontname/controller/function")); ?>
Run Code Online (Sandbox Code Playgroud)

这给了我一个看起来像这样的网址

http://www.mysite.com/customer/account/loginPost/referer/aHR0cDovL3J5YW4uZGV2L3VzL2Zyb250bmFtZS9jb250cm9sbGVyL2Z1bmN0aW9uLw,,/
Run Code Online (Sandbox Code Playgroud)

哪个有效,但我认为必须有更好的方法.任何人都有任何想法?

如果不是......这对我有用,以防其他人在寻找同样的事情.

小智 13

我已经这样做了,希望这对某些人也有帮助:

Mage::getUrl('customer/account/login', array('referer' => Mage::helper('core')->urlEncode($this->getUrl("frontname/controller/function"))))
Run Code Online (Sandbox Code Playgroud)


Mar*_*kie 2

我有同样的问题。由于您的配置中的设置,您的客户将被重定向到仪表板。去

系统 > 配置 > 客户 > 客户配置 > 登录选项

并将“登录后将客户重定向到帐户仪表板”设置为“否”。Magento 将开始侦听该引荐来源网址参数,并将您的客户带回到他们单击“登录”之前所在的页面。

我知道这是一个旧线程,可能为时已晚提供帮助,但这个问题符合问题,也许它会帮助其他人。