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;
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
add a comment |
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
add a comment |
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
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
magento2 customer redirect
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
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
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();
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 usingdie
function.
– Max
Oct 6 '17 at 16:38
@SnehaPanchal its working with the same version
– SagarPPanchal
Sep 18 '18 at 6:11
add a comment |
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;
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 ofMagento/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
add a comment |
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.
1
bad idea because your observer will interrupt application flow usingexit
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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();
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 usingdie
function.
– Max
Oct 6 '17 at 16:38
@SnehaPanchal its working with the same version
– SagarPPanchal
Sep 18 '18 at 6:11
add a comment |
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();
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 usingdie
function.
– Max
Oct 6 '17 at 16:38
@SnehaPanchal its working with the same version
– SagarPPanchal
Sep 18 '18 at 6:11
add a comment |
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();
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();
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 usingdie
function.
– Max
Oct 6 '17 at 16:38
@SnehaPanchal its working with the same version
– SagarPPanchal
Sep 18 '18 at 6:11
add a comment |
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 usingdie
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
add a comment |
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;
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 ofMagento/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
add a comment |
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;
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 ofMagento/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
add a comment |
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;
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;
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 ofMagento/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
add a comment |
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 ofMagento/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
add a comment |
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.
1
bad idea because your observer will interrupt application flow usingexit
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
add a comment |
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.
1
bad idea because your observer will interrupt application flow usingexit
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
add a comment |
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.
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.
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 usingexit
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
add a comment |
1
bad idea because your observer will interrupt application flow usingexit
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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