I have explained the method below for getting the list of Country which we see in Magento. site checkout page.
Below code to be written in Block file in a function (you can even write the code in template file).
<?php $collection = Mage::getModel('directory/country')->getCollection(); foreach ($collection as $country) { $cid = $country->getId(); $cname = $country->getName(); echo 'Country ID -> '.$cid.' Country Name -> '.$cname.'<br/>'; } ?>
Hope this is helpful to many of you.
Thanks for the code, GregC!
what if i want only the allowed countries out of this collection? is this possible? or is there any other way for doing it?
thanks,
Its configured from admin end (Admin > System > configuration > General),
great, thanks…
Thanks a lot !
Thanks! Here’s the code to turn this into a standalone php script
—
getCollection();
foreach ($collection as $country)
{
$cid = $country->getId();
$cname = $country->getName();
echo ‘Country ID -> ‘.$cid.’ Country Name -> ‘.$cname.”;
}
?>
great !