Archive for DB

How to add state country indian states in Magento

You can add states to countries in magento easily .
By default in magento only few countries have a state drop down when a country is selected like United States, in this post you can add state drop down for other countries as well.

 

The main table where are all the state values of a country are stored is directory_country_region and directory_country_region_name.
The fields of the table ‘directory_country_region’ are
1. region_id: auto-incremented id
2. country_id: the iso code of country (this code is taken from directory_country table)
3. code: unique code to be used for a state
4. default_name: name of the state

The second table is directory_country_region_name with fields
1. locale: website locale or language of the website
2. region_id: it’s a forign key from the previous table
3. name: name of the state for a specific language or locale.

The first table is required to add states to a country, the second table is only required if you want to state displayed in multiple languages.

So to add state to country India, we need to insert a row in the table directory_country_region