I need to be able to simulate the click of the drop-down of the view change but with code. I do not have space to put the drop-down and I would like to simulate the click by code but I have no idea how to do it. Could someone help me do this?
Hi @ManuelSissl
Try once using jQuery trigger with change event.
For more info:
https://api.jquery.com/change/
I hope it will help you!
Hi,
I created this plugin but it does not work, could you help me make the store view change work?
<?php
namespace MyPlugin\CustomerLogin\Plugin;
class LoginPostPlugin
{
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $_storeManagerInterface;
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManagerInterface
) {
$this->_storeManagerInterface = $storeManagerInterface;
}
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){
$this->_storeManagerInterface->setCurrentStore(2);
$result->setPath('?___store=DE&___from_store=DE');
}
}
return $result;
}
}My problem is that the change of view is applied correctly when the client of group 2 does log in, but if the client opens a product or opens a category, it loses the store view that it selects by code and returns to the previous store view. Could you help me please?