Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

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
$region = Mage::getModel('directory/region')->load(12);
$state_code = $region->getCode(); //CA

Get state name from state id
$region = Mage::getModel('directory/region')->load(12);
$state_name = $region->getName(); //California

Get state id from state code
$region = Mage::getModel('directory/region')->loadByCode('CA', 'US');
$state_id = $region->getId(); //12

Please support us, Like us on Facebook.

0 comments:

Post a Comment

 

Copyright @ 2017 HKBlog.