3

How can get store id by locale code right now I have

$locale='en_US';

reverse of this code

Mage::getStoreConfig('general/locale/code', $storeId);

now based on this I want to get store id I could not find possible way. any suggestion?

2 Answers 2

1

I think this code will do the trick for you.

 $locale='en_US';
 $allStores = Mage::app()->getStores();
 foreach ($allStores as $_eachStoreId):

     if($locale==Mage::getStoreConfig('general/locale/code',$_eachStoreId->getStoreId())):
       $storeId=$_eachStoreId->getStoreId();
       break;
     endif;
  endforeach;
  echo $storeId;  
2

There can be same local for multiple store thats why there is no alternative of this.

$locale='en_US';
$defaultStores = Mage::app()->getStores();
foreach ($defaultStores as $_store)
{
    if($locale==Mage::getStoreConfig('general/locale/code',$_store->getStoreId()))
    {
        $storeIds[]=$_store->getStoreId(); 
        // you can use break here if want first value only
    }
}
  echo '<pre>';print_r($storeIds);die;
3
  • This is same answer to @fmeExtensions Commented Nov 15, 2016 at 7:25
  • @QaisarSatti, Yes but he is consider only 1 store for 1 locale. But it may possible multiple store on a same locale. So technically his answer is wrong. Commented Nov 15, 2016 at 7:27
  • after testing both answers worked for me. but i need single store id. thanks for answer. Commented Nov 15, 2016 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.