X

Magento 2: Как установить текущий store

Установить текущий store в Magento 2 можно вот так..

1. Добавляем в зависимости экземпляр типа StoreManagerInterface

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

public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
    $this->_storeManager = $storeManager;
}

2. В нужном месте вызываем

$this->_storeManager->setCurrentStore('YOUR_STORE_ID');

 

Категории: Magento Бездна
Тэги: magentostore