Home » Magento9 December 2009

Magento: Get country and region collection

This article shows how to get all the country list and region list in Magento and then populate that list in a selection box.

Before going the code for fetching countries and regions, I would like to show a quick code to get country name by country code. Country code can be like NP (for Nepal), IN (for India), NL (for Netherlands), GB (for United Kingdom), US (for United States), etc.

Get country name by country code

Get collection of all countries

Populate selection list with the country collection

Get collection of all states/regions related to specific country

Populate region list with region collection

Country code (e.g. NP, IN, NL, GB, US, etc.) is passed as parameter to getRegionCollection function.

Hope it helps. Thanks.


Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • key

    i want to use admin grid modify region, add edit or delete, could you gei me some advices.

  • Hi,

    Thanx a lot !!! It saved my time !!! And also i found this blog is very helpful for magento beginners like myself. It turned out to be saviour for myself.All the posts regarding magento are really very handy during development. So my hearty appreciations , Kudos to you and kindly continue this good work.

    Best Regards,
    Jerome Dennis D

  • Parvezmca

    how to get country ‘name’ waise.here display country code wise.

  • Thanks Mukesh, here is another useful one:


    That will give you a list of all countries in the correct structure for a html select drop-down. Useful in frontend and adminhtml forms.


  • Pranalid15

    But how  can I get the country code $countryCode

  • Pritesh Modi

    In product import script if i found new country then how can i add new country by script??

  • thanks really worked!!!
    Here is another mothod
    Visit http://www.sumithnet.com

    *__(‘Country’) ?>
    ->toOptionArray(false) ?>
    0): ?>

    — Please Select —

    <option value="”>

  • Sunil830_talekar2007

    Great Work Mukesh Thanks

  • josh

    Returns erros to me when I use ‘public’. Whats going on?

  • Bhagwati

    use following code to the billing.php under core folder.

    public function getRegionCollection($countryCode)
    $regionCollection = Mage::getModel(‘directory/region_api’)->items($countryCode);
    return $regionCollection;

  • jafor iqbal

    Thanks for your great help