Social Icons

Pages

Monday, 10 September 2012

Add States to Country in Magento.

By default in magento only few countries have a state drop down when a country ( like United States) is selected. Here we will see how to add state drop down for other countries as well.
The main table where 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  state to be displayed in multiple languages.
So to add state to country Australia, we need to insert a row in the table directory_country_region.

insert into SCHEMA_NAME.directory_country_region (country_id,code,default_name) values ('AU','AU-NSW','New South Wales');
 




Here ‘AU’ is the country code for Australia, ‘AU-NSW’ is a user defined unique key and ‘New South Wales’ is the name of the state. Similarly we can add other states as well.

Let me know if you find any questions related to above tutorial.

3 comments:

  1. I have found an another solution at http://webdesignsolutions.co.in/add-country-and-state-dropdown-in-magento , it helps me a lot.

    ReplyDelete
  2. My product is Magento Checkout cart
    I had a issue during bug clearance of my client.
    When the product page is opened, ajax request is fired.

    What I have to do to resolve this problem?

    ReplyDelete
  3. Thanks for your ideas. You can also find the details on Affity Solutions, at the Magento Website. The main object of the Affity Solutions is to provide quality web services and is among the few software development company in Australia.

    ReplyDelete

 

Contact Us

info@intellozene.com

Our Website:
www.intellozene.com