Site icon Qaisar Satti's Blogs

Magento 2 store information

Magento 2 get store information

Magento 2 get store information

Today we talk about how to get Magento 2 store information. In Store information we get the current store id , store code , store website id ,store name and also the available currencies in current store.So let start with example.

<?php
namespace QaisarSatti\HelloWorld\Block;
class HelloWorld extends \Magento\Framework\View\Element\Template
{    
    public function __construct(
        \Magento\Backend\Block\Template\Context $context,        
        array $data = []
    )
    {            
        parent::__construct($context, $data);
    }
   public function getStoreInfromation()
   {
        return $this->_storeManager->getStore();
   }
}

In phtml file get the information

$storeInformation = $block->getStoreInfromation();

$storeInformation->getStoreId();  //get store id
$storeInformation->getCode();  // get store code
$storeInformation->getWebsiteId(); // get store website id
$storeInformation->getName();  //get store name

//To get available currencies in store you check

foreach($storeInformation->getAvailableCurrencyCodes() as $codes):
  echo $codes;
endforeach;
Exit mobile version