Magento2 – How to get Store Name

To get store name you need instance of \Magento\Framework\App\Config\ScopeConfigInterface You can get the instance by objectManager. Use the following code get the Store Name:
     $scope = \Magento\Framework\App\ObjectManager::getInstance()->get('\Magento\Framework\App\Config\ScopeConfigInterface');
      echo $scope->getValue(
            'general/store_information/name',
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE
        );  
If store name configuration is defined there then it will be printed otherwise the output will be blank.

Leave a Reply

Your email address will not be published. Required fields are marked *