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?

3 doors, three guards, one stone

Why didn't this character "real die" when they blew their stack out in Altered Carbon?

Why is my conclusion inconsistent with the van't Hoff equation?

When were vectors invented?

How do I stop a creek from eroding my steep embankment?

porting install scripts : can rpm replace apt?

Is it fair for a professor to grade us on the possession of past papers?

How to answer "Have you ever been terminated?"

Why are Kinder Surprise Eggs illegal in the USA?

Seeking colloquialism for “just because”

Can inflation occur in a positive-sum game currency system such as the Stack Exchange reputation system?

Generate an RGB colour grid

How to align text above triangle figure

Resolving to minmaj7

Why was the term "discrete" used in discrete logarithm?

2001: A Space Odyssey's use of the song "Daisy Bell" (Bicycle Built for Two); life imitates art or vice-versa?

Extract all GPU name, model and GPU ram

How to call a function with default parameter through a pointer to function that is the return of another function?

Bete Noir -- no dairy

What does an IRS interview request entail when called in to verify expenses for a sole proprietor small business?

How to tell that you are a giant?

Why did the IBM 650 use bi-quinary?

In predicate logic, does existential quantification (∃) include universal quantification (∀), i.e. can 'some' imply 'all'?

How to find out what spells would be useless to a blind NPC spellcaster?



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






























    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


























      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

      60.1k1677178




      60.1k1677178










      asked Oct 6 '17 at 10:14









      Sneha PanchalSneha Panchal

      540325




      540325




















          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,856818




          2,856818












          • 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,5182875




          2,5182875







          • 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

          Sum ergo cogito? 1 nng

          419 nièngy_Soadمي 19bal1.5o_g

          Queiggey Chernihivv 9NnOo i Zw X QqKk LpB