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?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI 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;
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;