How can I login customer in specific store programmatically in Magento 2?
I've tried to override execute method of


and did something like this:

$store = $this->storeRepository->getActiveStoreByCode("store_code");
$this->httpContext->setValue("store", "store_code", "default");

$customer = $this->customerAccountManagement->authenticate($login['username'], $login['password']);

But it didn't work.

I need to do main store, where customer will insert his credentials, and after that customer will logged in and redirected to store according to his customer group

  • why you don't use account share at option? – Amit Bera Oct 2 '18 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.