4

I have spent hours searching to find where magento stores full county name. We can get a full list of countries using this code:

$_countries = Mage::getResourceModel('directory/country_collection')
    ->loadData()
    ->toOptionArray(false);

This will return an array with country code and name, I investigated the directory module, and found out this call gets data from the table

directory_county

But this table don't have full county name! So where is it stored? and how is it retrieved using that call?

Thanks in advance.

kguest
  • 3,804
  • 3
  • 29
  • 31
rramiii
  • 1,156
  • 6
  • 15
  • 29

4 Answers4

6

Ok so to compensate for my wrong answer. Here is how this works:

  1. /lib/Zend/Locale/Data/en.xml - if your store is in english, else another xml in the same directoery is read. Every country is there and its code under the xml tag <territory>

  2. The xml is cached using the Zend_Cache_Core class.

  3. /lib/Zend/Locale.php - function getTranslation invokes the lib/Zend/Cache/Core.php class to load from the cache.

Example: If you change the name of some country in en.xml and clear the magento cache. You will see the change when u invoke your code again.

letsanov
  • 191
  • 12
1

Use the Zend_Local translation.

<?php
$code = 'EN';
echo Mage::app()->getLocale()->getTranslation($code, 'Territory', null, 2);
?>

Use the column 'iso2_code' from the table 'directory_country' for your $code.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
tommy
  • 66
  • 5
1

Full country names are not stored in database. Magento uses inbuilt Zend functionality.

Check file: lib/Zend/Locale/Data/Translation.php for full list.

Gerard de Visser
  • 7,590
  • 9
  • 50
  • 58
  • yes this file contains full list .. but I modified one country name and printed out all countries .. the change didn't appear :( I don't understand why !!!!! (I make sure there is no caching in browser) – rramiii Jul 24 '14 at 12:50
0

Magneto only stores country codes in DB, and relies for names on Zend's Locale module to provide translated names, for different locale.

By the toOptionArray method it invokes the Zend_Locale class to get the translated value.

Refer $name = Mage::app()->getLocale()->getCountryTranslation($data['value']);, which gets to Mage_Core_Model_Locale and then to Zend_Locale.

It decides which of the node from the data to read, by the switch case statement in Zend_Locale_Data::getContent() line# 962, 963

Magento caches the names, so if you make any change to XML files, make sure to clean your cache folder to get what you seek.

s_s_
  • 463
  • 5
  • 20