Im searching since a week how i can get a store_id / website_id for a given language.
Like:
$countryId = 'DE'; // or country = Germany
foreach (Mage::app()->getStores() as $store) {
if($store->getCountryId() === $countryId){
return $store;
}
}
How could i solve this?
EDIT: 03022016
Im now using the general/country/allow config (system/general/allowed countries)
This will get the first store that is using the given country.
Ofc the country could be used on multiply stores, but any other solution i found got the same problem.
The point why im using this solution is that the IDs are real country_id s (not editable codes-strings).
public function getStoreIdByCustomerCountryId($countryIdCustomer)
{
$countryIdReturn = null;
$countryIdCustomer = trim((string)$countryIdCustomer);
if (!strlen($countryIdCustomer)) {
return false;
}
foreach (Mage::app()->getStores() as $store) {
if (!$store->getIsActive()) {
continue;
}
foreach (
explode(',', $store->getConfig('general/country/allow'))
as $countryId
) {
if (trim((string)$countryId) === $countryIdCustomer) {
$countryIdReturn = $store->getId();
break 2;
}
}
}
return $countryIdReturn;
}