*/ class Mage_Sales_Model_Resource_Order_Attribute_Backend_Shipping extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract { /** * Perform operation before save * * @param Varien_Object $object */ public function beforeSave($object) { $shippingAddressId = $object->getShippingAddressId(); if (is_null($shippingAddressId)) { $object->unsetShippingAddressId(); } } /** * Perform operation after save * * @param Varien_Object $object */ public function afterSave($object) { $shippingAddressId = false; foreach ($object->getAddressesCollection() as $address) { if ('shipping' == $address->getAddressType()) { $shippingAddressId = $address->getId(); } } if ($shippingAddressId) { $object->setShippingAddressId($shippingAddressId); $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getAttributeCode()); } } }