eristoddle
12/21/2012 - 4:28 AM

Magento Get Countries

Magento Get Countries

	//$countryCollection = Mage::getModel('directory/country_api')->items();

	function getCountryId($country_name){
		global $countryCollection;
		$country_name = trim($country_name);
		foreach ($countryCollection as $country) {
			if (strtolower($country['name']) == strtolower($country_name)){
				return $country['country_id'];
			}elseif (strtolower($country['country_id']) == strtolower($country_name)) {
				return $country['country_id'];
			}elseif (strtolower($country['iso2_code']) == strtolower($country_name)) {
				return $country['country_id'];
			}elseif (strtolower($country['iso3_code']) == strtolower($country_name)) {
				return $country['country_id'];
			}
		}
		return false;
	}