javascript 客户登录 magento 后禁用重定向

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13839792/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 19:55:17  来源:igfitidea点击:

Disabling redirecting after customer login magento

magentoredirectaccountjavascript

提问by user1897753

All I want is to let a customer stay on his current page when he logs in to his Magento account.

我想要的只是让客户在登录到他的 Magento 帐户时停留在他的当前页面上。

Yes I know about the Magento backend option (found in: System > Configuration > Customers > Customer Configuration > Login Options) but when I turn this setting to NO it still redirects a customer to his account dashboard after loggin in.

是的,我知道 Magento 后端选项(可在:系统 > 配置 > 客户 > 客户配置 > 登录选项中找到)但是当我将此设置设置为“否”时,它仍会将客户在登录后重定向到他的帐户仪表板。

Is there really no simple way to let a customer stay on the same page from where he is logging in?

真的没有简单的方法可以让客户停留在他登录的同一页面上吗?

I know about the Magento connect Psycho extension or something :) but I just need a code to implement.

我知道 Magento connect Psycho 扩展或其他东西:) 但我只需要一个代码来实现。

Tia

蒂亚

回答by Fábio ZC

You should set to NOon System > Configuration > Customers > Customer Configuration > Login Options

你应该设置为NOSystem > Configuration > Customers > Customer Configuration > Login Options

and in your login.phtmlfiles (both, persistent/customer/formand customer/formon your template folder) you must change the action of your <form>to:

并且在您的login.phtml文件中(persistent/customer/form以及customer/form在您的模板文件夹中),您必须将您的操作更改<form>为:

    action="<?php echo str_replace('login', 'loginPost', $this->helper('customer')->getLoginUrl()) ?>"

OR

或者

Try this FREE extension

试试这个免费的扩展

http://www.magentocommerce.com/magento-connect/customer-redirect-after-login-5446.html

http://www.magentocommerce.com/magento-connect/customer-redirect-after-login-5446.html

回答by Alex

Can add follow code in login form phtml file

可以在登录表单 phtml 文件中添加以下代码

$refererUrl = $this->getRequest()->getServer('HTTP_REFERER');
Mage::getSingleton('customer/session')->setBeforeAuthUrl($refererUrl);

回答by Peter O'Callaghan

I'm guessing this will somewhat depend on the Magento version. In 1.7, if you check the function mentioned by @Rajat (loginPostRedirect), you'll see that the option you mention will only prevent the customer ending up on the dashboard if there is a referer param in the query string. If you add that query parameter to the action of the login form, you should be good to go.

我猜这在某种程度上取决于 Magento 版本。在 1.7 中,如果您检查 @Rajat ( loginPostRedirect)提到的函数,您会看到您提到的选项只会阻止客户在查询字符串中有引用参数时最终出现在仪表板上。如果您将该查询参数添加到登录表单的操作中,您应该很高兴。

回答by Rajat

For redirection you will have have to make changes to your Customer Controller.
For making changes in your controller better option would be to override your controller.
You will have to make change in loginPostRedirect() function in controller.
Make your changes to this line
$session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());

对于重定向,您必须对您的客户控制器进行更改。
为了在您的控制器中进行更改,更好的选择是覆盖您的控制器。
您必须在控制器中的 loginPostRedirect() 函数中进行更改。
对此行进行更改
$session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());