Jun 25, 2014
kalpesh

Magento get State Code, ID, Name from Region ID

Magento get state name, ID, code from region ID or region code.

Get state code from state id

1
2
$region = Mage::getModel('directory/region')->load(12);
$state_code = $region->getCode(); //CA

Get state name from state id

1
2
$region = Mage::getModel('directory/region')->load(12);
$state_name = $region->getName(); //California

Get state id from state code

1
2
$region = Mage::getModel('directory/region')->loadByCode('CA', 'US');
$state_id = $region->getId(); //12

Leave a comment

 

Welcome to my Blog

Kalpesh MehtaHelping Magento developers in their day-to-day development problems since 2011. Most of the problems and solutions here are my own experiences while working on different projects. Enjoy the blog and don't forget to throw comments and likes/+1's/tweets on posts you like. Thanks for visiting!

Certifications