*/ class Mage_Customer_Model_Resource_Address_Attribute_Backend_Region extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract { /** * Prepare object for save * * @param Varien_Object $object * @return Mage_Customer_Model_Resource_Address_Attribute_Backend_Region */ public function beforeSave($object) { $region = $object->getData('region'); if (is_numeric($region)) { $regionModel = Mage::getModel('directory/region')->load($region); if ($regionModel->getId() && $object->getCountryId() == $regionModel->getCountryId()) { $object->setRegionId($regionModel->getId()) ->setRegion($regionModel->getName()); } } return $this; } }