where magento stores country full name

where magento stores country full name

July 7, 2026 · Illustrated author avatarBy Stefan Bogdanescu
where magento stores country full name

Understanding Where Magento Stores Full Country Names

As a developer working with Magento, you might find yourself needing to retrieve full country names for various purposes such as displaying addresses or generating reports. The provided code snippet fetches an array of countries, but the question remains: where exactly is this data stored and how does it get retrieved?

Diving into the Directory Module The directory module in Magento manages various types of data including countries, regions, currencies, and time zones. When you call the following code:

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

It retrieves a collection of directory_country models from the database. The data is loaded into memory using $_countries->loadData(), which populates the object properties with information from the directory_country table.

Investigating the Directory Country Table The directory_country table stores country-related data, but you’ve correctly observed that it doesn’t contain a field for ‘full name’. The fields available are:

  • country_id: A unique identifier for each country.
  • iso2_code: The two-character ISO code for the country (e.g., US for United States).
  • iso3_code: The three-character ISO code for the country (e.g., USA for United States of America).

The full country name is not directly stored in this table, so we need to look further.

Understanding the Collection and Option Array When you call $_countries->toOptionArray(false), it transforms the collection into an option array suitable for use with HTML select elements. The false argument indicates that the model’s properties should be used as is, without any additional formatting.

Retrieving Country Names from the Database The country names are actually retrieved from a different table: directory_country_name. This table has fields for country name in various languages based on the locale specified.

In your case, if you’re using English (US) locale, Magento will query the directory_country_name table and join it with the directory_country table to get the full country names. The join is performed on the country_id field.

Example SQL Query Here’s an example of what the underlying SQL query might look like:

SELECT c.country_id, cn.value AS name
FROM directory_country c
INNER JOIN directory_country_name cn ON c.country_id = cn.country_id AND cn.locale = 'en_US'

In this query:

  • directory_country is aliased as c.
  • directory_country_name is aliased as cn.
  • The join condition matches the country IDs.
  • The locale column is set to 'en_US' to retrieve English (US) names.

Conclusion To summarize, Magento retrieves full country names by joining two tables: directory_country and directory_country_name. The directory_country_name table stores the country names in various languages based on the locale specified. Understanding this data structure and retrieval process is crucial for working with countries in your Magento projects.

Remember, the directory module provides a lot of flexibility for managing localized data like countries, regions, currencies, and more. Exploring its capabilities can help you build more robust internationalized solutions.

For further reading on Magento’s directory functionality, I recommend checking out our guide on Managing Localization in Magento at Laravel Company. It provides a detailed overview of how to work with locales and manage localized data effectively.

Happy coding!

Database Extensions

Our network