4

Is there a simple way to sovel redirect url customize in Magento?

I'v searched some articles mentions "controller".

But I have no idea about custom extensions.

How to override the base controller action with a extension?

1
  • @Emipro, why did you added "Magento 2" to the title?
    – Black
    Commented Dec 3, 2020 at 7:57

4 Answers 4

14

Just change the option:

System > Config > Customer 
> Costumer Redirect Customer to Account Dashboard after Logging in > NO
5
  • hi @Fabian what we have to do redirect from customer register to shopping cart/previous page? Commented May 28, 2015 at 11:33
  • 1
    As I said in the answer, change the option to no, so you should be redirected to the page before the login form. Commented May 29, 2015 at 5:38
  • 1
    in magento 2 Stores > Configuration > Customers > Customer Configuration > Login Options Commented Nov 4, 2016 at 4:18
  • But it's not working sir @FabianBlechschmidt Commented Jan 30, 2017 at 6:42
  • @AmareshTiwari If it is no magentos default behaviour is to redirect you to the page you came from or (if the form contained another page with a parameter I don't know currently) to a page defined in the form. So check the form, the request and if this doesn'T help, xdebug is your friend. Commented Jan 30, 2017 at 10:58
3

Do not change core/ code. Use the following free extension: http://www.magentocommerce.com/magento-connect/customer-redirect-after-login-1.html

Take a look at this answer for more details on how to do it yourself: https://stackoverflow.com/a/16099279/3403171

1

You can also use the

For Magento1.9.* as a $this->_redirectReferer();.

1

For this the config setting should be -> System -> Configuration -> CUSTOMERS -> Customer Configuration -> Login Options Set: Redirect Customers to Account Dashboard after Log in = No.

But there is some more work for this to do. For this you dont need to change anything in any class.

Just add below codes in you login form phtml within <form> tag.

<?php if (!Mage::getStoreConfigFlag(
        Mage_Customer_Helper_Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD
    )) { ?>
    <input name="referer" type="hidden" value="<?php echo Mage::helper('core')->urlEncode(Mage::getBaseUrl()); ?>" />
<?php } ?>

Example of a login form,

<form action="<?php echo $this->getPostActionUrl() ?>" method="post">
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />
<?php if (!Mage::getStoreConfigFlag(
        Mage_Customer_Helper_Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD
    )) { ?>
    <input name="referer" type="hidden" value="<?php echo Mage::helper('core')->urlEncode(Mage::getBaseUrl()); ?>" />
<?php } ?>
<div class="block-content">
    <label for="mini-login"><?php echo $this->__('Email address:') ?></label><input type="text" name="login[username]" id="mini-login" class="input-text" />
    <label for="mini-password"><?php echo $this->__('Password:') ?></label><input type="password" name="login[password]" id="mini-password" class="input-text" />
    <div class="mini-actions">
        <a href="<?php echo $this->getForgotPasswordUrl() ?>" class="f-left"><?php echo $this->__('Forgot Your Password?') ?></a>
        <button type="submit" class="button"><span><span><?php echo $this->__('Log in') ?></span></span></button>
    </div>
</div>

Hope it helps!! Please upvote and accept it if helps..!!

2
  • Your solution is for Magento 1
    – Black
    Commented Nov 18, 2020 at 13:06
  • 1
    Hi @Black, Magento 2.0 was released on November 17, 2015. And the question was asked originally on Mar 11 '14. I believe when I had answered 2.5 years ago, I would have seen the question was relevant to Magento 1. Someone possibly would have modify the question later.
    – Sandipan S
    Commented Dec 2, 2020 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.