/** * Method is invoked before save * * @param Varien_Object $object * @return Mage_Sales_Model_Resource_Order_Invoice_Attribute_Backend_Order */ public function beforeSave($object) { if ($object->getOrder()) { $object->setOrderId($object->getOrder()->getId()); $object->setBillingAddressId($object->getOrder()->getBillingAddress()->getId()); } return parent::beforeSave($object); }
/** * Perform operation after save * * @param Varien_Object $object */ public function afterSave($object) { $billingAddressId = false; foreach ($object->getAddressesCollection() as $address) { if ('billing' == $address->getAddressType()) { $billingAddressId = $address->getId(); } } if ($billingAddressId) { $object->setBillingAddressId($billingAddressId); $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getAttributeCode()); } }