*/ class Mage_Sales_Model_Order_Address extends Mage_Customer_Model_Address_Abstract { protected $_order; protected $_eventPrefix = 'sales_order_address'; protected $_eventObject = 'address'; /** * Initialize resource */ protected function _construct() { $this->_init('sales/order_address'); } /** * Init mapping array of short fields to its full names * * @return Mage_Sales_Model_Order_Address */ protected function _initOldFieldsMap() { $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_address'); return $this; } /** * Set order * * @return Mage_Sales_Model_Order_Address */ public function setOrder(Mage_Sales_Model_Order $order) { $this->_order = $order; return $this; } /** * Get order * * @return Mage_Sales_Model_Order */ public function getOrder() { if (!$this->_order) { $this->_order = Mage::getModel('sales/order')->load($this->getParentId()); } return $this->_order; } /** * Before object save manipulations * * @return Mage_Sales_Model_Order_Address */ protected function _beforeSave() { parent::_beforeSave(); if (!$this->getParentId() && $this->getOrder()) { $this->setParentId($this->getOrder()->getId()); } // Init customer address id if customer address is assigned if ($this->getCustomerAddress()) { $this->setCustomerAddressId($this->getCustomerAddress()->getId()); } return $this; } }