14

How to add Indian State lists to the corresponding country?

6 Answers 6

23

Run following command in your Database ;

INSERT INTO `directory_country_region` VALUES
    (NULL , 'IN', 'AN','Andaman Nicobar'),
    (NULL , 'IN', 'AP','Andhra Pradesh'),
    (NULL , 'IN', 'AR','Arunachal Pradesh'),
    (NULL , 'IN', 'AS','Assam'),
    (NULL , 'IN', 'BH','Bihar'),
    (NULL , 'IN', 'CH','Chandigarh'),
    (NULL , 'IN', 'CG','Chhattisgarh'),
    (NULL , 'IN', 'DN','Dadra Nagar Haveli'),
    (NULL , 'IN', 'DD','Daman Diu'),
    (NULL , 'IN', 'DL','Delhi'),
    (NULL , 'IN', 'GA','Goa'),
    (NULL , 'IN', 'GJ','Gujarat'),
    (NULL , 'IN', 'HR','Haryana'),
    (NULL , 'IN', 'HP','Himachal Pradesh'),
    (NULL , 'IN', 'JK','Jammu Kashmir'),
    (NULL , 'IN', 'JH','Jharkhand'),
    (NULL , 'IN', 'KA','Karnataka'),
    (NULL , 'IN', 'KL','Kerala'),
    (NULL , 'IN', 'LD','Lakshadweep'),
    (NULL , 'IN', 'MP','Madhya Pradesh'),
    (NULL , 'IN', 'MH','Maharashtra'),
    (NULL , 'IN', 'MN','Manipur'),
    (NULL , 'IN', 'ML','Meghalaya'),
    (NULL , 'IN', 'MZ','Mizoram'),
    (NULL , 'IN', 'NL','Nagaland'),
    (NULL , 'IN', 'OR','Odisha'),
    (NULL , 'IN', 'PY','Pondicherry'),
    (NULL , 'IN', 'PB','Punjab'),
    (NULL , 'IN', 'RJ','Rajasthan'),
    (NULL , 'IN', 'SK','Sikkim'),
    (NULL , 'IN', 'TN','Tamil Nadu'),
    (NULL , 'IN', 'TG','Telangana'),
    (NULL , 'IN', 'TR','Tripura'),
    (NULL , 'IN', 'UP','Uttar Pradesh'),
    (NULL , 'IN', 'UT','Uttaranchal'),
    (NULL , 'IN', 'WB','West Bengal');
1
  • My site two years old, just now i updates above command when i go to checkout, for all users asking the select state, but we know customer state, how can i assign the state to the customer for 100k customers.
    – Gem
    Commented Apr 19, 2018 at 9:00
13

Magento did not provide regions for a few Country in its region directry.Most country do not have it own region/state like india,nepal etc...

Step1:

First magento save region list at directory_country_region table: So insert new region list on with respective country in this table: directory_country_region

Run the query

   INSERT INTO `directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES
    (NULL, 'IN', 'ANDRA', 'Andra Pradesh'),
    (NULL, 'IN', 'ARUNA', 'Arunachal Pradesh'),
    (NULL, 'IN', 'ASSAM', 'Assam'),
    (NULL, 'IN', 'BIHAR', 'Bihar'),
    (NULL, 'IN', 'CHAND', 'Chandigarh'),
    (NULL, 'IN', 'CHHAT', 'Chhattisgarh'),
    (NULL, 'IN', 'DADAR', 'Dadar and Nagar Haveli'),
    (NULL, 'IN', 'DAMAN', 'Daman and Diu'),
    (NULL, 'IN', 'DELHI', 'Delhi'),
    (NULL, 'IN', 'GOA', 'Goa'),
    (NULL, 'IN', 'GUJAR', 'Gujarat'),
    (NULL, 'IN', 'HARYA', 'Haryana'),
    (NULL, 'IN', 'HP', 'Himachal Pradesh'),
    (NULL, 'IN', 'JK', 'Jammu and Kashmir'),
    (NULL, 'IN', 'JHARK', 'Jharkhand'),
    (NULL, 'IN', 'KARNA', 'Karnataka'),
    (NULL, 'IN', 'KERAL', 'Kerala'),
    (NULL, 'IN', 'LAKSH', 'Lakshadeep'),
    (NULL, 'IN', 'MP', 'Madya Pradesh'),
    (NULL, 'IN', 'MAHAR', 'Maharashtra'),
    (NULL, 'IN', 'MANIP', 'Manipur'),
    (NULL, 'IN', 'MEGHA', 'Meghalaya'),
    (NULL, 'IN', 'MIZOR', 'Mizoram'),
    (NULL, 'IN', 'NAGAL', 'Nagaland'),
    (NULL, 'IN', 'ORISS', 'Orissa'),
    (NULL, 'IN', 'PONDI', 'Pondicherry'),
    (NULL, 'IN', 'PUNJA', 'Punjab'),
    (NULL, 'IN', 'RAJAS', 'Rajasthan'),
    (NULL, 'IN', 'SIKKI', 'Sikkim'),
    (NULL, 'IN', 'TAMIL', 'Tamil Nadu'),
    (NULL, 'IN', 'TAMIL', 'Tripura'),
    (NULL, 'IN', 'UP', 'Uttar Pradesh'),
    (NULL, 'IN', 'UTTAR', 'Uttaranchal'),
    (NULL, 'IN', 'WB', 'West Bengal');

Step2: Also you need insert directory_country_region_name for language wish region name.

as default indian people is use en_us(language code ) as default language

Using below code:

INSERT INTO directory_country_region_name( locale, region_id, name )
SELECT 'en_US' AS "language", region_id, default_name
FROM `directory_country_region`
WHERE country_id = 'IN';

This last insert is import if you have multiple lauguage

5
  • My site two years old, just now i updates above command when i go to checkout, for all users asking the select state, but we know customer state, how can i assign the state to the customer for 100k customers.
    – Gem
    Commented Apr 19, 2018 at 8:59
  • yes, you can do. but need some custom script to update there region_id
    – Amit Bera
    Commented Apr 19, 2018 at 9:18
  • Could you kindly help me to do that?
    – Gem
    Commented Apr 19, 2018 at 9:32
  • First get customer/address collection from Mage::getResourceModel('customer/address_collection')->addAttributeToSelect('region_id')->->addAttributeToSelect('region'); `$addressObject->getResource()->saveAttribute($addressObject, 'attribute_Code');
    – Amit Bera
    Commented Apr 19, 2018 at 9:34
  • I am newbie for core, pls help me how can i run your above code and get my details
    – Gem
    Commented Apr 19, 2018 at 9:45
4

Updated state list

INSERT INTO `directory_country_region` VALUES
(NULL , 'IN', 'AN','Andaman and Nicobar'),
(NULL , 'IN', 'AP','Andhra Pradesh'),
(NULL , 'IN', 'AR','Arunachal Pradesh'),
(NULL , 'IN', 'AS','Assam'),
(NULL , 'IN', 'BH','Bihar'),
(NULL , 'IN', 'CH','Chandigarh'),
(NULL , 'IN', 'CT','Chhattisgarh'),
(NULL , 'IN', 'DN','Dadra and Nagar Haveli'),
(NULL , 'IN', 'DD','Daman and Diu'),
(NULL , 'IN', 'DL','Delhi'),
(NULL , 'IN', 'GA','Goa'),
(NULL , 'IN', 'GJ','Gujarat'),
(NULL , 'IN', 'HR','Haryana'),
(NULL , 'IN', 'HP','Himachal Pradesh'),
(NULL , 'IN', 'JK','Jammu Kashmir'),
(NULL , 'IN', 'JH','Jharkhand'),
(NULL , 'IN', 'KA','Karnataka'),
(NULL , 'IN', 'KL','Kerala'),
(NULL , 'IN', 'LD','Lakshadweep'),
(NULL , 'IN', 'MP','Madhya Pradesh'),
(NULL , 'IN', 'MH','Maharashtra'),
(NULL , 'IN', 'MN','Manipur'),
(NULL , 'IN', 'ML','Meghalaya'),
(NULL , 'IN', 'MZ','Mizoram'),
(NULL , 'IN', 'NL','Nagaland'),
(NULL , 'IN', 'OR','Odisha'),
(NULL , 'IN', 'PY','Pondicherry'),
(NULL , 'IN', 'PB','Punjab'),
(NULL , 'IN', 'RJ','Rajasthan'),
(NULL , 'IN', 'SK','Sikkim'),
(NULL , 'IN', 'TN','Tamil Nadu'),
(NULL , 'IN', 'TG','Telangana'),
(NULL , 'IN', 'TR','Tripura'),
(NULL , 'IN', 'UP','Uttar Pradesh'),
(NULL , 'IN', 'UT','Uttarakhand'),
(NULL , 'IN', 'WB','West Bengal');
4

Magento is using directory_country_region table to store the state names.

You can add states into table by run query in database as following:

INSERT INTO `directory_country_region` (`region_id`, `country_id`,`code`, `default_name`) VALUES
(NULL, 'IN', 'ANDRA', 'Andra Pradesh'),
(NULL, 'IN', 'ARUNA', 'Arunachal Pradesh'),
(NULL, 'IN', 'ASSAM', 'Assam'),
(NULL, 'IN', 'BIHAR', 'Bihar'),
(NULL, 'IN', 'CHAND', 'Chandigarh'),
(NULL, 'IN', 'CHHAT', 'Chhattisgarh'),
(NULL, 'IN', 'DADAR', 'Dadar and Nagar Haveli'),
(NULL, 'IN', 'DAMAN', 'Daman and Diu'),
(NULL, 'IN', 'DELHI', 'Delhi'),
(NULL, 'IN', 'GOA', 'Goa'),
(NULL, 'IN', 'GUJAR', 'Gujarat'),
(NULL, 'IN', 'HARYA', 'Haryana'),
(NULL, 'IN', 'HP', 'Himachal Pradesh'),
(NULL, 'IN', 'JK', 'Jammu and Kashmir'),
(NULL, 'IN', 'JHARK', 'Jharkhand'),
(NULL, 'IN', 'KARNA', 'Karnataka'),
(NULL, 'IN', 'KERAL', 'Kerala'),
(NULL, 'IN', 'LAKSH', 'Lakshadeep'),
(NULL, 'IN', 'MP', 'Madya Pradesh'),
(NULL, 'IN', 'MAHAR', 'Maharashtra'),
(NULL, 'IN', 'MANIP', 'Manipur'),
(NULL, 'IN', 'MEGHA', 'Meghalaya'),
(NULL, 'IN', 'MIZOR', 'Mizoram'),
(NULL, 'IN', 'NAGAL', 'Nagaland'),
(NULL, 'IN', 'ORISS', 'Orissa'),
(NULL, 'IN', 'PONDI', 'Pondicherry'),
(NULL, 'IN', 'PUNJA', 'Punjab'),
(NULL, 'IN', 'RAJAS', 'Rajasthan'),
(NULL, 'IN', 'SIKKI', 'Sikkim'),
(NULL, 'IN', 'TAMIL', 'Tamil Nadu'),
(NULL, 'IN', 'TAMIL', 'Tripura'),
(NULL, 'IN', 'UP', 'Uttar Pradesh'),
(NULL, 'IN', 'UTTAR', 'Uttaranchal'),
(NULL, 'IN', 'WB', 'West Bengal');

you can also add state of other country by adding country code, state code and state name as above.

1
  • My site two years old, just now i updates above command when i go to checkout, for all users asking the select state, but we know customer state, how can i assign the state to the customer for 100k customers.
    – Gem
    Commented Apr 19, 2018 at 9:00
3

Updated States as of 3rd July 2015

Login to cpanel go to database and then go to directory_country_region table and their click on the SQL tab and add the following code

INSERT INTO `directory_country_region` VALUES
(NULL , 'IN', 'AN','Andaman and Nicobar Islands'),
(NULL , 'IN', 'AP','Andhra Pradesh'),
(NULL , 'IN', 'AR','Arunachal Pradesh'),
(NULL , 'IN', 'AS','Assam'),
(NULL , 'IN', 'BR','Bihar'),
(NULL , 'IN', 'CH','Chandigarh'),
(NULL , 'IN', 'CT','Chhattisgarh'),
(NULL , 'IN', 'DN','Dadra and Nagar Haveli'),
(NULL , 'IN', 'DD','Daman and Diu'),
(NULL , 'IN', 'DL','Delhi'),
(NULL , 'IN', 'GA','Goa'),
(NULL , 'IN', 'GJ','Gujarat'),
(NULL , 'IN', 'HR','Haryana'),
(NULL , 'IN', 'HP','Himachal Pradesh'),
(NULL , 'IN', 'JK','Jammu and Kashmir'),
(NULL , 'IN', 'JH','Jharkhand'),
(NULL , 'IN', 'KA','Karnataka'),
(NULL , 'IN', 'KL','Kerala'),
(NULL , 'IN', 'LD','Lakshadweep'),
(NULL , 'IN', 'MP','Madhya Pradesh'),
(NULL , 'IN', 'MH','Maharashtra'),
(NULL , 'IN', 'MN','Manipur'),
(NULL , 'IN', 'ML','Meghalaya'),
(NULL , 'IN', 'MZ','Mizoram'),
(NULL , 'IN', 'NL','Nagaland'),
(NULL , 'IN', 'OR','Odisha'),
(NULL , 'IN', 'PY','Puducherry'),
(NULL , 'IN', 'PB','Punjab'),
(NULL , 'IN', 'RJ','Rajasthan'),
(NULL , 'IN', 'SK','Sikkim'),
(NULL , 'IN', 'TN','Tamil Nadu'),
(NULL , 'IN', 'TG','Telangana'),
(NULL , 'IN', 'TR','Tripura'),
(NULL , 'IN', 'UP','Uttar Pradesh'),
(NULL , 'IN', 'UT','Uttarakhand'),
(NULL , 'IN', 'WB','West Bengal');

for an updated list of countries check same answer on my blog

1
  • more preferable way add as a update sql script in Magento, so works on local and remote instances.
    – huzefam
    Commented Oct 27, 2015 at 6:11
0

Adding the list of states in India to Magento


I have tested this and worked for me on my server.
Please open your php my admin and run following:
INSERT INTO directory_country_region VALUES
(NULL , "IN", "Andaman and Nicobar","Andaman and Nicobar"),
(NULL , "IN", "Andhra Pradesh","Andhra Pradesh"),
(NULL , "IN", "Arunachal Pradesh","Arunachal Pradesh"),
(NULL , "IN", "Assam","Assam"),
(NULL , "IN", "Bihar","Bihar"),
(NULL , "IN", "Chandigarh","Chandigarh"),
(NULL , "IN", "Chhattisgarh","Chhattisgarh"),
(NULL , "IN", "Dadra and Nagar Haveli","Dadra and Nagar Haveli"),
(NULL , "IN", "Daman and Diu","Daman and Diu"),
(NULL , "IN", "Delhi","Delhi"),
(NULL , "IN", "Goa","Goa"),
(NULL , "IN", "Gujarat","Gujarat"),
(NULL , "IN", "Haryana","Haryana"),
(NULL , "IN", "Himachal Pradesh","Himachal Pradesh"),
(NULL , "IN", "Jammu and Kashmir","Jammu and Kashmir"),
(NULL , "IN", "Jharkhand","Jharkhand"),
(NULL , "IN", "Karnataka","Karnataka"),
(NULL , "IN", "Kerala","Kerala"),
(NULL , "IN", "Lakshadweep","Lakshadweep"),
(NULL , "IN", "Madhya Pradesh","Madhya Pradesh"),
(NULL , "IN", "Maharashtra","Maharashtra"),
(NULL , "IN", "Manipur","Manipur"),
(NULL , "IN", "Meghalaya","Meghalaya"),
(NULL , "IN", "Mizoram","Mizoram"),
(NULL , "IN", "Nagaland","Nagaland"),
(NULL , "IN", "Orissa","Orissa"),
(NULL , "IN", "Pondicherry","Pondicherry"),
(NULL , "IN", "Punjab","Punjab"),
(NULL , "IN", "Rajasthan","Rajasthan"),
(NULL , "IN", "Sikkim","Sikkim"),
(NULL , "IN", "Tamil Nadu","Tamil Nadu"),
(NULL , "IN", "Tripura","Tripura"),
(NULL , "IN", "Uttar Pradesh","Uttar Pradesh"),
(NULL , "IN", "Uttaranchal","Uttaranchal"),
(NULL , "IN", "West Bengal","West Bengal");

INSERT INTO directory_country_region_name (locale ,region_id ,name ) SELECT 'en_US', tmp.region_id, tmp.default_name FROM directory_country_region AS tmp WHERE tmp.country_id='IN';


I hope it will help to you. http://tejabhagavan.blogspot.in/2015/12/adding-list-of-states-in-india-to.html

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