5/17/2011

How to get all list of country in magento

Write the following code to any phtml file or template file you will get list of all the Country

<select name="country" id="country">
<?php $country_list = Mage::getResourceModel('directory/country_collection')
->loadData()
->toOptionArray(false) ?>
<?php if (count($country_list) > 0){ ?>
<option value="">Please Select</option>
<?php foreach($country_list as $country){ ?>
<option value="<?php echo $country['value'] ?>">
<?php echo $country['label'] ?>
</option>
<?php } ?>
<?php }?>
</select>

No comments:

Post a Comment