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'); |
Author: Vitaly Orlov
| Rating: 4/5 |
Tags: magento , store
Leave a Reply