Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies

Saturday, June 29, 2013

How to get store URL by store code or store Id

Here are 2 ways to get home URL of Magento stores
1. By store CODE
01
02
03
04
05
06
07
08
09
10
11
12
13
function getStoreByCode($storeCode)
{
        $stores = array_keys(Mage::app()->getStores());
        foreach($stores as $id){
          $store = Mage::app()->getStore($id);
          if($store->getCode()==$storeCode) {
            return $store;
          }
         }
         return null; // if not found
}
$store = getStoreByCode('default');
$store->getUrl('');


2. By store ID
1
2
$storeId = 1;
Mage::getModel('core/store')->load($storeId)->getUrl('');

No comments:

Post a Comment