$collection = Mage::getModel('custom/table')->getCollection();

I have one custom table and there is one field country_code.
Now I am passing this $collection to my javascript and using variables in that.
Now I want to display country name instead of country code.

Is there any way from which I can add country name in my collection using join query or any way else ?
so before passing to js I want country name in my collection object.

4 Answers 4


Try this.

$countryModel = Mage::getModel('directory/country')->loadByCode($country_code);
$countryName = $countryModel->getName();

In order to get the country name in English locale:

$locale = new Zend_Locale('en_US');
echo $locale->getTranslation($code, 'country', $locale);
  • To get default locale, use Mage::app()->getLocale()->getTranslation($code, 'country');
    – kiatng
    Jan 31, 2020 at 8:37

you can try below code

echo $country_name;
  • Is it possible to get by join query ? so it can be new column in my collection object. Feb 3, 2014 at 10:33
  • you have to design your table in such a way that you can easily got that value when you fetch your custom collection then you got this values
    – Keyul Shah
    Feb 3, 2014 at 10:37

You can retrieve the country name by country ID/code this way:

echo Mage::getModel(’directory/country’)->load($country_id)->getName();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.