Magento: Get store information

Magento allows to maintain multiple websites from single backend admin. Furthermore, each website can have multiple stores. Below is the code to get Magento store information like store id, store code, store name, etc. All of these functions can be found in class Mage_Core_Model_Store.

Get store data array


// Get all store data in an array
Mage::app()->getStore();

Get store ID

Mage::app()->getStore()->getStoreId();

Get store code

Mage::app()->getStore()->getCode();

Get website ID of store

Mage::app()->getStore()->getWebsiteId();

Get store name

Mage::app()->getStore()->getName();

Check if store is active

Mage::app()->getStore()->getIsActive();

Get homepage URL of the store

Mage::app()->getStore()->getHomeUrl(); 

Get current page URL of the store

Mage::app()->getStore()->getCurrentUrl();

Hope it helps. Thanks.