*/ class Mage_Sales_Model_Entity_Order_Attribute_Backend_Billing extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract { /** * Before save order billing address process * * @param Mage_Sales_Model_Order $object * @return Mage_Sales_Model_Entity_Order_Attribute_Backend_Billing */ public function beforeSave($object) { $billingAddressId = $object->getBillingAddressId(); if (is_null($billingAddressId)) { $object->unsetBillingAddressId(); } return $this; } /** * After save order billing address process * * @param Mage_Sales_Model_Order $object * @return Mage_Sales_Model_Entity_Order_Attribute_Backend_Billing */ public function afterSave($object) { $billingAddressId = false; foreach ($object->getAddressesCollection() as $address) { /* @var $address Mage_Sales_Model_Order_Address */ if ('billing' == $address->getAddressType()) { $billingAddressId = $address->getId(); } } if ($billingAddressId) { $object->setBillingAddressId($billingAddressId); $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getAttributeCode()); } return $this; } }