Pages

Sunday, September 6, 2015

Magento 2: Get the Current Store

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
}

No comments:

Post a Comment