I have read this manual and I have adapted my code with this:
<?php
namespace MyPlugin\CustomerLogin\Plugin;
class LoginPostPlugin
{
public function afterExecute(
\Magento\Customer\Controller\Account\LoginPost $subject,
$result)
{
//-- check group is retail customer or not
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->create('Magento\Customer\Model\Session');
if ($customerSession->isLoggedIn()){
$groupId = $customerSession->getCustomerGroupId();
if ($groupId == 2){
$result->setPath('?___store=Wholesale&___from_store=Wholesale');
}
}
return $result;
}
}
And the view changes to the selected view (wholesale), but when I open a product or a category, the view changes to the predefined view, the change does not become effective. Any other idea of being able to make the fixed exchange?
Does anyone know how to solve this?