Magento 2 redirect to a specific store view programatically

Use StoreManagerInterface to set current store. You can use observer to do so.

/**
 * @var \Magento\Store\Model\StoreManagerInterface
 */
protected $_storeManagerInterface;


//Inject your class
public function __construct(
    \Magento\Store\Model\StoreManagerInterface $storeManagerInterface
) {
    $this->_storeManagerInterface = $storeManagerInterface;
}

// Use It in your method
public function execute(){
    $this->_storeManagerInterface->setCurrentStore(1);
}

Tags:

Geoip

Magento2