Get region_id From State Abbreviation - Magento 1.4.2

VinnyD picture VinnyD · Mar 29, 2011 · Viewed 15.1k times · Source

How can I programmatically get the region_id in Magento from a 2-character state abbreviation? I'm using Magento 1.4.2 if that matters at all.

Answer

Christopher Manning picture Christopher Manning · Mar 29, 2011
$regionModel = Mage::getModel('directory/region')->loadByCode($regionCode, $countryCode);
$regionId = $regionModel->getId();