HummingbirdUK main logo

Coding solutions to business problems

About us

We use code to create solutions to business challenges, bottle-necks and headaches.

If you think your business has a problem that can be solved through code, we are happy to chat things through without any obligation.

Get in touch

Get Store IDs in Magento

Home / Blog / Get Store IDs in Magento

Written by Giles Bennett

Most of the time scripts will operate at the default store level. But in case you need to target a specific store, and don't know the ID, then the following simple script will list store IDs for each store on your domain.

Start off with the usual gubbins :

require_once 'app/Mage.php';

Then load all the stores into the $everyStore variable

$everyStore = Mage::app()->getStores();

Then loop through each of the stores and output the relevant information :

foreach ($everyStore as $eachStore => $val) {
  $storeCode = Mage::app()->getStore($eachStore)->getCode();
  $storeName = Mage::app()->getStore($eachStore)->getName();
  $storeID = Mage::app()->getStore($eachStore)->getId();
  echo "Code : " . $storeCode . "</br>Name : " . $storeName . "</br>ID : " . $storeID . "</br> </br>";

Then finish off :


That's all there is to it!

Author : Giles Bennett

About the author

Giles Bennett built his first website in 1996, and is old enough to miss Netscape Navigator. Initially a lawyer, he jumped ship to IT in 2008, and after 5 years as a freelancer, he founded HummingbirdUK in 2013. He can be reached by email at