Magento 2 – How to Get Store Name in Template

magento2storestemplate

How is it possible to output the current store name in a Magento 2 custom template with a custom block?

Best Answer

you need to use the instance of \Magento\Framework\App\Config\ScopeConfigInterface in your block:

Create the method getStoreName()

public function getStoreName()
{
    return $this->_scopeConfig->getValue(
        'general/store_information/name',
        \Magento\Store\Model\ScopeInterface::SCOPE_STORE
    );
}

and call in your template echo $this->getStoreName()