1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Sales
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Flat sales order address resource
30: *
31: * @category Mage
32: * @package Mage_Sales
33: * @author Magento Core Team <core@magentocommerce.com>
34: */
35: class Mage_Sales_Model_Resource_Order_Address extends Mage_Sales_Model_Resource_Order_Abstract
36: {
37: /**
38: * Event prefix
39: *
40: * @var string
41: */
42: protected $_eventPrefix = 'sales_order_address_resource';
43:
44: /**
45: * Resource initialization
46: *
47: */
48: protected function _construct()
49: {
50: $this->_init('sales/order_address', 'entity_id');
51: }
52:
53: /**
54: * Return configuration for all attributes
55: *
56: * @return array
57: */
58: public function getAllAttributes()
59: {
60: $attributes = array(
61: 'city' => Mage::helper('sales')->__('City'),
62: 'company' => Mage::helper('sales')->__('Company'),
63: 'country_id' => Mage::helper('sales')->__('Country'),
64: 'email' => Mage::helper('sales')->__('Email'),
65: 'firstname' => Mage::helper('sales')->__('First Name'),
66: 'lastname' => Mage::helper('sales')->__('Last Name'),
67: 'region_id' => Mage::helper('sales')->__('State/Province'),
68: 'street' => Mage::helper('sales')->__('Street Address'),
69: 'telephone' => Mage::helper('sales')->__('Telephone'),
70: 'postcode' => Mage::helper('sales')->__('Zip/Postal Code')
71: );
72: asort($attributes);
73: return $attributes;
74: }
75:
76: /**
77: * Update related grid table after object save
78: *
79: * @param Varien_Object $object
80: * @return Mage_Core_Model_Resource_Db_Abstract
81: */
82: protected function _afterSave(Mage_Core_Model_Abstract $object)
83: {
84: $resource = parent::_afterSave($object);
85: if ($object->hasDataChanges() && $object->getOrder()) {
86: $gridList = array(
87: 'sales/order' => 'entity_id',
88: 'sales/order_invoice' => 'order_id',
89: 'sales/order_shipment' => 'order_id',
90: 'sales/order_creditmemo' => 'order_id'
91: );
92:
93: // update grid table after grid update
94: foreach ($gridList as $gridResource => $field) {
95: Mage::getResourceModel($gridResource)->updateOnRelatedRecordChanged(
96: $field,
97: $object->getParentId()
98: );
99: }
100: }
101:
102: return $resource;
103: }
104: }
105: