Use this below code to get the store code using store id
Mage::app()->getStore($StoreId)->getCode();
Note:
Magento provides a single function getStore() by which you can get store data
by store id or store code.
In Magento, you can load the store Object by code /id
on getStore() function.
After that from that StoreObject
you can get store code or store id as per as your requirement
see at Mage_Core_Model_App
class function at getStore()
.
On this function if your parameter is numeric then * store object is loaded by store id*
if (is_numeric($id)) {
$store->load($id);
}
if param is string then load store object by store code
elseif (is_string($id)) {
$store->load($id, 'code');
}
if (empty($this->_stores[$id])) {
$store = Mage::getModel('core/store');
/* @var $store Mage_Core_Model_Store */
if (is_numeric($id)) {
$store->load($id);
} elseif (is_string($id)) {
$store->load($id, 'code');
}
if (!$store->getCode()) {
$this->throwStoreException();
}
$this->_stores[$store->getStoreId()] = $store;
$this->_stores[$store->getCode()] = $store;
}