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 :
<?php
require_once 'app/Mage.php';
Mage::app();
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!