Here is code for get current store in magento 2:
Get the Current store in Magento 2
protected $_storeManager;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
array $data = []
) {
parent::__construct($context, $data);
$this->_storeManager = $storeManager;
}
public function getCurrentStore(){
return $this->_storeManager->getStore(); // give the information about current store
}
Get the Current store in Magento 2
protected $_storeManager;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
array $data = []
) {
parent::__construct($context, $data);
$this->_storeManager = $storeManager;
}
public function getCurrentStore(){
return $this->_storeManager->getStore(); // give the information about current store
}
No comments:
Post a Comment