Magento 2 : Redirect on cart page after login Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Redirect user after loginCustomer login redirect to homepageRedirect Registered Customer issueMagento 2: How to redirect customer to login pageRedirect to login page if not login magentoRedirect to login page after registration in Magento 2Magento 2 After login redirect user to referrerMagento 1.9 checkout/onepage after login redirect to checkout/onepageMagento 1: after login need to redirect to previous page (before login) instead of dashboard pageHow to redirect customer to cart page if they are login from checkout page?

Is there a documented rationale why the House Ways and Means chairman can demand tax info?

How do I automatically answer y in bash script?

Why use gamma over alpha radiation?

How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time

Was credit for the black hole image misattributed?

How to retrograde a note sequence in Finale?

What is the electric potential inside a point charge?

I'm thinking of a number

Fishing simulator

When is phishing education going too far?

Make it rain characters

Mortgage adviser recommends a longer term than necessary combined with overpayments

Autumning in love

Complexity of many constant time steps with occasional logarithmic steps

Simulating Exploding Dice

What to do with post with dry rot?

Can I throw a sword that doesn't have the Thrown property at someone?

I'm having difficulty getting my players to do stuff in a sandbox campaign

If A makes B more likely then B makes A more likely"

Estimate capacitor parameters

Replacing HDD with SSD; what about non-APFS/APFS?

Am I ethically obligated to go into work on an off day if the reason is sudden?

The following signatures were invalid: EXPKEYSIG 1397BC53640DB551

What do you call a plan that's an alternative plan in case your initial plan fails?



Magento 2 : Redirect on cart page after login



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Redirect user after loginCustomer login redirect to homepageRedirect Registered Customer issueMagento 2: How to redirect customer to login pageRedirect to login page if not login magentoRedirect to login page after registration in Magento 2Magento 2 After login redirect user to referrerMagento 1.9 checkout/onepage after login redirect to checkout/onepageMagento 1: after login need to redirect to previous page (before login) instead of dashboard pageHow to redirect customer to cart page if they are login from checkout page?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I want to redirect the customer to cart page after login from anywhere ex.login from checkout page or customer account login.



Anyone know how to do this?



Please help me.










share|improve this question
















bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.





















    1















    I want to redirect the customer to cart page after login from anywhere ex.login from checkout page or customer account login.



    Anyone know how to do this?



    Please help me.










    share|improve this question
















    bumped to the homepage by Community 2 days ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

















      1












      1








      1








      I want to redirect the customer to cart page after login from anywhere ex.login from checkout page or customer account login.



      Anyone know how to do this?



      Please help me.










      share|improve this question
















      I want to redirect the customer to cart page after login from anywhere ex.login from checkout page or customer account login.



      Anyone know how to do this?



      Please help me.







      magento2 customer redirect






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 7 '17 at 14:15









      Amit Bera

      60k1677178




      60k1677178










      asked Oct 6 '17 at 10:14









      Sneha PanchalSneha Panchal

      540325




      540325





      bumped to the homepage by Community 2 days ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 2 days ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















          3 Answers
          3






          active

          oldest

          votes


















          0














          Step 1 : Create




          Vendor/Module/etc/frontend/events.xml




          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">

          <event name="customer_login">
          <observer name="customer_login_observer" instance="VendorModuleObserverCustomerLogin" />
          </event>

          </config>


          Step 2 :




          Create Vendor/Module/Observer/CustomerLogin.php




          <?php

          namespace VendorModuleObserver;

          use MagentoFrameworkEventObserver;
          use MagentoFrameworkEventObserverInterface;

          class CustomerLogin implements ObserverInterface

          protected $_responseFactory;
          protected $_url;

          public function __construct(
          MagentoFrameworkViewLayout $layout,
          MagentoFrameworkAppResponseFactory $responseFactory,
          MagentoFrameworkUrlInterface $url,
          )

          $this->_layout = $layout;
          $this->_responseFactory = $responseFactory;
          $this->_url = $url;


          public function execute(MagentoFrameworkEventObserver $observer)

          /*$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
          $resultRedirect->setUrl('checkout/cart');
          return $resultRedirect;*/
          $RedirectUrl = $this->_url->getUrl('checkout/cart');
          $this->_responseFactory->create()->setRedirect($RedirectUrl)->sendResponse();
          die();







          share|improve this answer























          • I'm using magento 2.1.8.it's not working.I'm getting 302 response from customer/ajax/login when I use your code.

            – Sneha Panchal
            Oct 6 '17 at 11:47







          • 2





            bad idea because your observer will interrupt application flow using die function.

            – Max
            Oct 6 '17 at 16:38











          • @SnehaPanchal its working with the same version

            – SagarPPanchal
            Sep 18 '18 at 6:11


















          0














          For customization after-login redirect you need to add after plugin on MagentoCustomerControllerAccountLoginPost::execute where you should check is customer logged in and create custom redirect result.



          Example



          public function afterExecute(LoginPost $subject, ResultInterface $result)

          $isCustomerLoggedIn = $this->httpContext->getValue(Context::CONTEXT_AUTH);
          if ($isCustomerLoggedIn)
          $result = $this->resultRedirectFactory->create()
          ->setPath('checkout/cart');


          return $result;






          share|improve this answer























          • This is not working on checkout page with ajax login method Also It is redirecting after customer create and we want to redirect after login to cart page from checkout page.

            – Sneha Panchal
            Oct 9 '17 at 6:19











          • yes, you also need to change behavior of Magento/Checkout/view/frontend/web/js/view/authentication.js component for redirect to custom url during login via checkout page

            – Max
            Oct 9 '17 at 7:48












          • Can I use something else for module development? Because we need to install the module on different instances. Thank You!

            – Sneha Panchal
            Oct 9 '17 at 10:20











          • i do not propose to change core files, you can use some techniques for js component customization's via your modules, such as mixins for example devdocs.magento.com/guides/v2.2/javascript-dev-guide/javascript/…

            – Max
            Oct 9 '17 at 10:28



















          0














          Create events.xml from Module/etc/frontend/ folder and paste it below code.



          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd">

          <event name="customer_login">
          <observer name="custom_customer_login" instance="ThemeVendorNameObserverRedirectCustomerToLoginAtObserver" />
          </event>

          </config>


          And create RedirectCustomerToLoginAtObserver.php file from Module/Observer folder and paste it below code.



          <?php

          namespace ThemeVendorNameObserver;

          class RedirectCustomerToLoginAtObserver implements MagentoFrameworkEventObserverInterface

          /**
          * @var MagentoFrameworkAppResponseInterface
          */
          protected $_response;

          /**
          * @var MagentoStoreModelStoreManagerInterface
          */
          protected $_storeManager;

          /**
          * @param MagentoFrameworkUrlInterface $url
          * @param MagentoStoreModelStoreManagerInterface $storeManagerInterface
          */
          public function __construct
          (
          MagentoFrameworkUrlInterface $url,
          MagentoStoreModelStoreManagerInterface $storeManagerInterface
          )
          $this->_storeManager = $storeManagerInterface;
          $this->_url = $url;


          public function execute(MagentoFrameworkEventObserver $observer)

          $storeObj = $this->_storeManager->getStore(1);
          $BaseURL = $storeObj->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_WEB);
          $url = $BaseURL . 'customer/account/login';
          $this->_response->setRedirect($url)->sendResponse();




          Feel free to ask if any.






          share|improve this answer




















          • 1





            bad idea because your observer will interrupt application flow using exit function.

            – Max
            Oct 6 '17 at 16:38











          • It is not working for me :(

            – Sneha Panchal
            Oct 9 '17 at 10:21











          • @SnehaPanchal let me check

            – Bojjaiah
            Oct 9 '17 at 10:37











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f196170%2fmagento-2-redirect-on-cart-page-after-login%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Step 1 : Create




          Vendor/Module/etc/frontend/events.xml




          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">

          <event name="customer_login">
          <observer name="customer_login_observer" instance="VendorModuleObserverCustomerLogin" />
          </event>

          </config>


          Step 2 :




          Create Vendor/Module/Observer/CustomerLogin.php




          <?php

          namespace VendorModuleObserver;

          use MagentoFrameworkEventObserver;
          use MagentoFrameworkEventObserverInterface;

          class CustomerLogin implements ObserverInterface

          protected $_responseFactory;
          protected $_url;

          public function __construct(
          MagentoFrameworkViewLayout $layout,
          MagentoFrameworkAppResponseFactory $responseFactory,
          MagentoFrameworkUrlInterface $url,
          )

          $this->_layout = $layout;
          $this->_responseFactory = $responseFactory;
          $this->_url = $url;


          public function execute(MagentoFrameworkEventObserver $observer)

          /*$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
          $resultRedirect->setUrl('checkout/cart');
          return $resultRedirect;*/
          $RedirectUrl = $this->_url->getUrl('checkout/cart');
          $this->_responseFactory->create()->setRedirect($RedirectUrl)->sendResponse();
          die();







          share|improve this answer























          • I'm using magento 2.1.8.it's not working.I'm getting 302 response from customer/ajax/login when I use your code.

            – Sneha Panchal
            Oct 6 '17 at 11:47







          • 2





            bad idea because your observer will interrupt application flow using die function.

            – Max
            Oct 6 '17 at 16:38











          • @SnehaPanchal its working with the same version

            – SagarPPanchal
            Sep 18 '18 at 6:11















          0














          Step 1 : Create




          Vendor/Module/etc/frontend/events.xml




          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">

          <event name="customer_login">
          <observer name="customer_login_observer" instance="VendorModuleObserverCustomerLogin" />
          </event>

          </config>


          Step 2 :




          Create Vendor/Module/Observer/CustomerLogin.php




          <?php

          namespace VendorModuleObserver;

          use MagentoFrameworkEventObserver;
          use MagentoFrameworkEventObserverInterface;

          class CustomerLogin implements ObserverInterface

          protected $_responseFactory;
          protected $_url;

          public function __construct(
          MagentoFrameworkViewLayout $layout,
          MagentoFrameworkAppResponseFactory $responseFactory,
          MagentoFrameworkUrlInterface $url,
          )

          $this->_layout = $layout;
          $this->_responseFactory = $responseFactory;
          $this->_url = $url;


          public function execute(MagentoFrameworkEventObserver $observer)

          /*$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
          $resultRedirect->setUrl('checkout/cart');
          return $resultRedirect;*/
          $RedirectUrl = $this->_url->getUrl('checkout/cart');
          $this->_responseFactory->create()->setRedirect($RedirectUrl)->sendResponse();
          die();







          share|improve this answer























          • I'm using magento 2.1.8.it's not working.I'm getting 302 response from customer/ajax/login when I use your code.

            – Sneha Panchal
            Oct 6 '17 at 11:47







          • 2





            bad idea because your observer will interrupt application flow using die function.

            – Max
            Oct 6 '17 at 16:38











          • @SnehaPanchal its working with the same version

            – SagarPPanchal
            Sep 18 '18 at 6:11













          0












          0








          0







          Step 1 : Create




          Vendor/Module/etc/frontend/events.xml




          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">

          <event name="customer_login">
          <observer name="customer_login_observer" instance="VendorModuleObserverCustomerLogin" />
          </event>

          </config>


          Step 2 :




          Create Vendor/Module/Observer/CustomerLogin.php




          <?php

          namespace VendorModuleObserver;

          use MagentoFrameworkEventObserver;
          use MagentoFrameworkEventObserverInterface;

          class CustomerLogin implements ObserverInterface

          protected $_responseFactory;
          protected $_url;

          public function __construct(
          MagentoFrameworkViewLayout $layout,
          MagentoFrameworkAppResponseFactory $responseFactory,
          MagentoFrameworkUrlInterface $url,
          )

          $this->_layout = $layout;
          $this->_responseFactory = $responseFactory;
          $this->_url = $url;


          public function execute(MagentoFrameworkEventObserver $observer)

          /*$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
          $resultRedirect->setUrl('checkout/cart');
          return $resultRedirect;*/
          $RedirectUrl = $this->_url->getUrl('checkout/cart');
          $this->_responseFactory->create()->setRedirect($RedirectUrl)->sendResponse();
          die();







          share|improve this answer













          Step 1 : Create




          Vendor/Module/etc/frontend/events.xml




          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">

          <event name="customer_login">
          <observer name="customer_login_observer" instance="VendorModuleObserverCustomerLogin" />
          </event>

          </config>


          Step 2 :




          Create Vendor/Module/Observer/CustomerLogin.php




          <?php

          namespace VendorModuleObserver;

          use MagentoFrameworkEventObserver;
          use MagentoFrameworkEventObserverInterface;

          class CustomerLogin implements ObserverInterface

          protected $_responseFactory;
          protected $_url;

          public function __construct(
          MagentoFrameworkViewLayout $layout,
          MagentoFrameworkAppResponseFactory $responseFactory,
          MagentoFrameworkUrlInterface $url,
          )

          $this->_layout = $layout;
          $this->_responseFactory = $responseFactory;
          $this->_url = $url;


          public function execute(MagentoFrameworkEventObserver $observer)

          /*$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
          $resultRedirect->setUrl('checkout/cart');
          return $resultRedirect;*/
          $RedirectUrl = $this->_url->getUrl('checkout/cart');
          $this->_responseFactory->create()->setRedirect($RedirectUrl)->sendResponse();
          die();








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 6 '17 at 10:57









          Dinesh YadavDinesh Yadav

          4,0831937




          4,0831937












          • I'm using magento 2.1.8.it's not working.I'm getting 302 response from customer/ajax/login when I use your code.

            – Sneha Panchal
            Oct 6 '17 at 11:47







          • 2





            bad idea because your observer will interrupt application flow using die function.

            – Max
            Oct 6 '17 at 16:38











          • @SnehaPanchal its working with the same version

            – SagarPPanchal
            Sep 18 '18 at 6:11

















          • I'm using magento 2.1.8.it's not working.I'm getting 302 response from customer/ajax/login when I use your code.

            – Sneha Panchal
            Oct 6 '17 at 11:47







          • 2





            bad idea because your observer will interrupt application flow using die function.

            – Max
            Oct 6 '17 at 16:38











          • @SnehaPanchal its working with the same version

            – SagarPPanchal
            Sep 18 '18 at 6:11
















          I'm using magento 2.1.8.it's not working.I'm getting 302 response from customer/ajax/login when I use your code.

          – Sneha Panchal
          Oct 6 '17 at 11:47






          I'm using magento 2.1.8.it's not working.I'm getting 302 response from customer/ajax/login when I use your code.

          – Sneha Panchal
          Oct 6 '17 at 11:47





          2




          2





          bad idea because your observer will interrupt application flow using die function.

          – Max
          Oct 6 '17 at 16:38





          bad idea because your observer will interrupt application flow using die function.

          – Max
          Oct 6 '17 at 16:38













          @SnehaPanchal its working with the same version

          – SagarPPanchal
          Sep 18 '18 at 6:11





          @SnehaPanchal its working with the same version

          – SagarPPanchal
          Sep 18 '18 at 6:11













          0














          For customization after-login redirect you need to add after plugin on MagentoCustomerControllerAccountLoginPost::execute where you should check is customer logged in and create custom redirect result.



          Example



          public function afterExecute(LoginPost $subject, ResultInterface $result)

          $isCustomerLoggedIn = $this->httpContext->getValue(Context::CONTEXT_AUTH);
          if ($isCustomerLoggedIn)
          $result = $this->resultRedirectFactory->create()
          ->setPath('checkout/cart');


          return $result;






          share|improve this answer























          • This is not working on checkout page with ajax login method Also It is redirecting after customer create and we want to redirect after login to cart page from checkout page.

            – Sneha Panchal
            Oct 9 '17 at 6:19











          • yes, you also need to change behavior of Magento/Checkout/view/frontend/web/js/view/authentication.js component for redirect to custom url during login via checkout page

            – Max
            Oct 9 '17 at 7:48












          • Can I use something else for module development? Because we need to install the module on different instances. Thank You!

            – Sneha Panchal
            Oct 9 '17 at 10:20











          • i do not propose to change core files, you can use some techniques for js component customization's via your modules, such as mixins for example devdocs.magento.com/guides/v2.2/javascript-dev-guide/javascript/…

            – Max
            Oct 9 '17 at 10:28
















          0














          For customization after-login redirect you need to add after plugin on MagentoCustomerControllerAccountLoginPost::execute where you should check is customer logged in and create custom redirect result.



          Example



          public function afterExecute(LoginPost $subject, ResultInterface $result)

          $isCustomerLoggedIn = $this->httpContext->getValue(Context::CONTEXT_AUTH);
          if ($isCustomerLoggedIn)
          $result = $this->resultRedirectFactory->create()
          ->setPath('checkout/cart');


          return $result;






          share|improve this answer























          • This is not working on checkout page with ajax login method Also It is redirecting after customer create and we want to redirect after login to cart page from checkout page.

            – Sneha Panchal
            Oct 9 '17 at 6:19











          • yes, you also need to change behavior of Magento/Checkout/view/frontend/web/js/view/authentication.js component for redirect to custom url during login via checkout page

            – Max
            Oct 9 '17 at 7:48












          • Can I use something else for module development? Because we need to install the module on different instances. Thank You!

            – Sneha Panchal
            Oct 9 '17 at 10:20











          • i do not propose to change core files, you can use some techniques for js component customization's via your modules, such as mixins for example devdocs.magento.com/guides/v2.2/javascript-dev-guide/javascript/…

            – Max
            Oct 9 '17 at 10:28














          0












          0








          0







          For customization after-login redirect you need to add after plugin on MagentoCustomerControllerAccountLoginPost::execute where you should check is customer logged in and create custom redirect result.



          Example



          public function afterExecute(LoginPost $subject, ResultInterface $result)

          $isCustomerLoggedIn = $this->httpContext->getValue(Context::CONTEXT_AUTH);
          if ($isCustomerLoggedIn)
          $result = $this->resultRedirectFactory->create()
          ->setPath('checkout/cart');


          return $result;






          share|improve this answer













          For customization after-login redirect you need to add after plugin on MagentoCustomerControllerAccountLoginPost::execute where you should check is customer logged in and create custom redirect result.



          Example



          public function afterExecute(LoginPost $subject, ResultInterface $result)

          $isCustomerLoggedIn = $this->httpContext->getValue(Context::CONTEXT_AUTH);
          if ($isCustomerLoggedIn)
          $result = $this->resultRedirectFactory->create()
          ->setPath('checkout/cart');


          return $result;







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 6 '17 at 16:36









          MaxMax

          2,846818




          2,846818












          • This is not working on checkout page with ajax login method Also It is redirecting after customer create and we want to redirect after login to cart page from checkout page.

            – Sneha Panchal
            Oct 9 '17 at 6:19











          • yes, you also need to change behavior of Magento/Checkout/view/frontend/web/js/view/authentication.js component for redirect to custom url during login via checkout page

            – Max
            Oct 9 '17 at 7:48












          • Can I use something else for module development? Because we need to install the module on different instances. Thank You!

            – Sneha Panchal
            Oct 9 '17 at 10:20











          • i do not propose to change core files, you can use some techniques for js component customization's via your modules, such as mixins for example devdocs.magento.com/guides/v2.2/javascript-dev-guide/javascript/…

            – Max
            Oct 9 '17 at 10:28


















          • This is not working on checkout page with ajax login method Also It is redirecting after customer create and we want to redirect after login to cart page from checkout page.

            – Sneha Panchal
            Oct 9 '17 at 6:19











          • yes, you also need to change behavior of Magento/Checkout/view/frontend/web/js/view/authentication.js component for redirect to custom url during login via checkout page

            – Max
            Oct 9 '17 at 7:48












          • Can I use something else for module development? Because we need to install the module on different instances. Thank You!

            – Sneha Panchal
            Oct 9 '17 at 10:20











          • i do not propose to change core files, you can use some techniques for js component customization's via your modules, such as mixins for example devdocs.magento.com/guides/v2.2/javascript-dev-guide/javascript/…

            – Max
            Oct 9 '17 at 10:28

















          This is not working on checkout page with ajax login method Also It is redirecting after customer create and we want to redirect after login to cart page from checkout page.

          – Sneha Panchal
          Oct 9 '17 at 6:19





          This is not working on checkout page with ajax login method Also It is redirecting after customer create and we want to redirect after login to cart page from checkout page.

          – Sneha Panchal
          Oct 9 '17 at 6:19













          yes, you also need to change behavior of Magento/Checkout/view/frontend/web/js/view/authentication.js component for redirect to custom url during login via checkout page

          – Max
          Oct 9 '17 at 7:48






          yes, you also need to change behavior of Magento/Checkout/view/frontend/web/js/view/authentication.js component for redirect to custom url during login via checkout page

          – Max
          Oct 9 '17 at 7:48














          Can I use something else for module development? Because we need to install the module on different instances. Thank You!

          – Sneha Panchal
          Oct 9 '17 at 10:20





          Can I use something else for module development? Because we need to install the module on different instances. Thank You!

          – Sneha Panchal
          Oct 9 '17 at 10:20













          i do not propose to change core files, you can use some techniques for js component customization's via your modules, such as mixins for example devdocs.magento.com/guides/v2.2/javascript-dev-guide/javascript/…

          – Max
          Oct 9 '17 at 10:28






          i do not propose to change core files, you can use some techniques for js component customization's via your modules, such as mixins for example devdocs.magento.com/guides/v2.2/javascript-dev-guide/javascript/…

          – Max
          Oct 9 '17 at 10:28












          0














          Create events.xml from Module/etc/frontend/ folder and paste it below code.



          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd">

          <event name="customer_login">
          <observer name="custom_customer_login" instance="ThemeVendorNameObserverRedirectCustomerToLoginAtObserver" />
          </event>

          </config>


          And create RedirectCustomerToLoginAtObserver.php file from Module/Observer folder and paste it below code.



          <?php

          namespace ThemeVendorNameObserver;

          class RedirectCustomerToLoginAtObserver implements MagentoFrameworkEventObserverInterface

          /**
          * @var MagentoFrameworkAppResponseInterface
          */
          protected $_response;

          /**
          * @var MagentoStoreModelStoreManagerInterface
          */
          protected $_storeManager;

          /**
          * @param MagentoFrameworkUrlInterface $url
          * @param MagentoStoreModelStoreManagerInterface $storeManagerInterface
          */
          public function __construct
          (
          MagentoFrameworkUrlInterface $url,
          MagentoStoreModelStoreManagerInterface $storeManagerInterface
          )
          $this->_storeManager = $storeManagerInterface;
          $this->_url = $url;


          public function execute(MagentoFrameworkEventObserver $observer)

          $storeObj = $this->_storeManager->getStore(1);
          $BaseURL = $storeObj->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_WEB);
          $url = $BaseURL . 'customer/account/login';
          $this->_response->setRedirect($url)->sendResponse();




          Feel free to ask if any.






          share|improve this answer




















          • 1





            bad idea because your observer will interrupt application flow using exit function.

            – Max
            Oct 6 '17 at 16:38











          • It is not working for me :(

            – Sneha Panchal
            Oct 9 '17 at 10:21











          • @SnehaPanchal let me check

            – Bojjaiah
            Oct 9 '17 at 10:37















          0














          Create events.xml from Module/etc/frontend/ folder and paste it below code.



          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd">

          <event name="customer_login">
          <observer name="custom_customer_login" instance="ThemeVendorNameObserverRedirectCustomerToLoginAtObserver" />
          </event>

          </config>


          And create RedirectCustomerToLoginAtObserver.php file from Module/Observer folder and paste it below code.



          <?php

          namespace ThemeVendorNameObserver;

          class RedirectCustomerToLoginAtObserver implements MagentoFrameworkEventObserverInterface

          /**
          * @var MagentoFrameworkAppResponseInterface
          */
          protected $_response;

          /**
          * @var MagentoStoreModelStoreManagerInterface
          */
          protected $_storeManager;

          /**
          * @param MagentoFrameworkUrlInterface $url
          * @param MagentoStoreModelStoreManagerInterface $storeManagerInterface
          */
          public function __construct
          (
          MagentoFrameworkUrlInterface $url,
          MagentoStoreModelStoreManagerInterface $storeManagerInterface
          )
          $this->_storeManager = $storeManagerInterface;
          $this->_url = $url;


          public function execute(MagentoFrameworkEventObserver $observer)

          $storeObj = $this->_storeManager->getStore(1);
          $BaseURL = $storeObj->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_WEB);
          $url = $BaseURL . 'customer/account/login';
          $this->_response->setRedirect($url)->sendResponse();




          Feel free to ask if any.






          share|improve this answer




















          • 1





            bad idea because your observer will interrupt application flow using exit function.

            – Max
            Oct 6 '17 at 16:38











          • It is not working for me :(

            – Sneha Panchal
            Oct 9 '17 at 10:21











          • @SnehaPanchal let me check

            – Bojjaiah
            Oct 9 '17 at 10:37













          0












          0








          0







          Create events.xml from Module/etc/frontend/ folder and paste it below code.



          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd">

          <event name="customer_login">
          <observer name="custom_customer_login" instance="ThemeVendorNameObserverRedirectCustomerToLoginAtObserver" />
          </event>

          </config>


          And create RedirectCustomerToLoginAtObserver.php file from Module/Observer folder and paste it below code.



          <?php

          namespace ThemeVendorNameObserver;

          class RedirectCustomerToLoginAtObserver implements MagentoFrameworkEventObserverInterface

          /**
          * @var MagentoFrameworkAppResponseInterface
          */
          protected $_response;

          /**
          * @var MagentoStoreModelStoreManagerInterface
          */
          protected $_storeManager;

          /**
          * @param MagentoFrameworkUrlInterface $url
          * @param MagentoStoreModelStoreManagerInterface $storeManagerInterface
          */
          public function __construct
          (
          MagentoFrameworkUrlInterface $url,
          MagentoStoreModelStoreManagerInterface $storeManagerInterface
          )
          $this->_storeManager = $storeManagerInterface;
          $this->_url = $url;


          public function execute(MagentoFrameworkEventObserver $observer)

          $storeObj = $this->_storeManager->getStore(1);
          $BaseURL = $storeObj->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_WEB);
          $url = $BaseURL . 'customer/account/login';
          $this->_response->setRedirect($url)->sendResponse();




          Feel free to ask if any.






          share|improve this answer















          Create events.xml from Module/etc/frontend/ folder and paste it below code.



          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd">

          <event name="customer_login">
          <observer name="custom_customer_login" instance="ThemeVendorNameObserverRedirectCustomerToLoginAtObserver" />
          </event>

          </config>


          And create RedirectCustomerToLoginAtObserver.php file from Module/Observer folder and paste it below code.



          <?php

          namespace ThemeVendorNameObserver;

          class RedirectCustomerToLoginAtObserver implements MagentoFrameworkEventObserverInterface

          /**
          * @var MagentoFrameworkAppResponseInterface
          */
          protected $_response;

          /**
          * @var MagentoStoreModelStoreManagerInterface
          */
          protected $_storeManager;

          /**
          * @param MagentoFrameworkUrlInterface $url
          * @param MagentoStoreModelStoreManagerInterface $storeManagerInterface
          */
          public function __construct
          (
          MagentoFrameworkUrlInterface $url,
          MagentoStoreModelStoreManagerInterface $storeManagerInterface
          )
          $this->_storeManager = $storeManagerInterface;
          $this->_url = $url;


          public function execute(MagentoFrameworkEventObserver $observer)

          $storeObj = $this->_storeManager->getStore(1);
          $BaseURL = $storeObj->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_WEB);
          $url = $BaseURL . 'customer/account/login';
          $this->_response->setRedirect($url)->sendResponse();




          Feel free to ask if any.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 27 '18 at 6:22









          Dhaduk Mitesh

          656218




          656218










          answered Oct 6 '17 at 10:38









          BojjaiahBojjaiah

          2,5132875




          2,5132875







          • 1





            bad idea because your observer will interrupt application flow using exit function.

            – Max
            Oct 6 '17 at 16:38











          • It is not working for me :(

            – Sneha Panchal
            Oct 9 '17 at 10:21











          • @SnehaPanchal let me check

            – Bojjaiah
            Oct 9 '17 at 10:37












          • 1





            bad idea because your observer will interrupt application flow using exit function.

            – Max
            Oct 6 '17 at 16:38











          • It is not working for me :(

            – Sneha Panchal
            Oct 9 '17 at 10:21











          • @SnehaPanchal let me check

            – Bojjaiah
            Oct 9 '17 at 10:37







          1




          1





          bad idea because your observer will interrupt application flow using exit function.

          – Max
          Oct 6 '17 at 16:38





          bad idea because your observer will interrupt application flow using exit function.

          – Max
          Oct 6 '17 at 16:38













          It is not working for me :(

          – Sneha Panchal
          Oct 9 '17 at 10:21





          It is not working for me :(

          – Sneha Panchal
          Oct 9 '17 at 10:21













          @SnehaPanchal let me check

          – Bojjaiah
          Oct 9 '17 at 10:37





          @SnehaPanchal let me check

          – Bojjaiah
          Oct 9 '17 at 10:37

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f196170%2fmagento-2-redirect-on-cart-page-after-login%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

          Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

          Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림