Tag Archives: magento get current store categories

Magento get current store information


Magento get current store information : If you are looking about the current store information in magento you can use $store = Mage::app()->getStore(); to get current store instance and details such as –

  • Store Id
  • Store Name
  • Store Code
  • Store Url
  • Store Status
  • Store Categories
  • Store Language
  • Store Currency Symbol
  • Store Country
  • Store Website Id
  • Store Group Id

Magento get current store information

Here We are going to show the store information listed above-

Magento get current store

Get Current Store :

 $store = Mage::app()->getStore();

Magento get current store Id

Get Current Store Id:

 $storeId = Mage::app()->getStore()->getStoreId();

Magento get current store Name

Get Current Store Name:

 $storeName = Mage::app()->getStore()->getName();

Magento get current store Code

Get Current Store Code:

 $storeCode = Mage::app()->getStore()->getCode();

Magento get current store Url

Get Current Store Code:

 $storeUrl = Mage::app()->getStore()->getHomeUrl();

Magento get current store Status

Get Current Store Status:

 $storeStatus = Mage::app()->getStore()->getIsActive();

Magento get current store Categories

You Can Use following method to get store categories – first get store id, get root category id then load category collection as below –

Get Current Store Categories:

            $storeId = Mage::app()->getStore()->getStoreId();


            $rootCategoryId = Mage::app()->getStore($storeId)->getRootCategoryId();


            $categoriesCollection = Mage::getModel('catalog/category')
                ->getCollection()
                ->setStoreId($storeId)
                ->addFieldToFilter('is_active', 1)
                ->addAttributeToFilter('path', array('like' => "1/{$rootCategoryId}/%"))
                ->addAttributeToSelect('*');
             foreach($categoriesCollection as $cat)
                {
                    $id = $cat->getId();                   
                    $name = $cat->getName();             
                }

Magento get current store Locale

Get Current Store Locale:

 $storeStatus = Mage::app()->getStore()->getLocaleCode();

Magento get current Currency code And Symbol

First get currency code then get corresponding symbol.

Get Current Store Currency Code And Symbol:

 $currencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
 $currencySymbol = Mage::app()->getLocale()->currency( $currencyCode )->getSymbol();

Magento get current Country Code

Get Current Country Code:

 $countryCode = Mage::getStoreConfig('general/country/default');

Magento get Current Store website Id

You can get website Id as below –

Get Current Store Website Id:

 $storeWebsiteId = Mage::app()->getStore()->getWebsiteId();

Magento get Current Store Group Id

You can get website Id as below –

Get Current Store Group Id:

 $storeGroupId = Mage::app()->getStore()->getGroupId();