File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed
app/code/core/Mage/Customer/Model Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -421,9 +421,11 @@ public function getAddressesCollection()
421
421
if ($ this ->_addressesCollection === null ) {
422
422
$ this ->_addressesCollection = $ this ->getAddressCollection ()
423
423
->setCustomerFilter ($ this )
424
- ->addAttributeToSelect ('* ' );
424
+ ->addAttributeToSelect ('* ' )
425
+ ->setOrder ('entity_id ' , 'desc ' );
425
426
foreach ($ this ->_addressesCollection as $ address ) {
426
427
$ address ->setCustomer ($ this );
428
+ $ address ->setDataChanges (false );
427
429
}
428
430
}
429
431
Original file line number Diff line number Diff line change @@ -134,8 +134,8 @@ protected function _afterSave(Varien_Object $customer)
134
134
*/
135
135
protected function _saveAddresses (Mage_Customer_Model_Customer $ customer )
136
136
{
137
- $ defaultBillingId = $ customer ->getData ('default_billing ' );
138
- $ defaultShippingId = $ customer ->getData ('default_shipping ' );
137
+ $ defaultBillingId = $ customer ->getData ('default_billing ' );
138
+ $ defaultShippingId = $ customer ->getData ('default_shipping ' );
139
139
foreach ($ customer ->getAddresses () as $ address ) {
140
140
if ($ address ->getData ('_deleted ' )) {
141
141
if ($ address ->getId () == $ defaultBillingId ) {
@@ -146,10 +146,19 @@ protected function _saveAddresses(Mage_Customer_Model_Customer $customer)
146
146
}
147
147
$ address ->delete ();
148
148
} else {
149
- $ address ->setParentId ($ customer ->getId ())
150
- ->setStoreId ($ customer ->getStoreId ())
151
- ->setIsCustomerSaveTransaction (true )
152
- ->save ();
149
+ if ($ address ->getParentId () != $ customer ->getId ()) {
150
+ $ address ->setParentId ($ customer ->getId ());
151
+ }
152
+
153
+ if ($ address ->hasDataChanges ()) {
154
+ $ address ->setStoreId ($ customer ->getStoreId ())
155
+ ->setIsCustomerSaveTransaction (true )
156
+ ->save ();
157
+ } else {
158
+ $ address ->setStoreId ($ customer ->getStoreId ())
159
+ ->setIsCustomerSaveTransaction (true );
160
+ }
161
+
153
162
if (($ address ->getIsPrimaryBilling () || $ address ->getIsDefaultBilling ())
154
163
&& $ address ->getId () != $ defaultBillingId
155
164
) {
You can’t perform that action at this time.
0 commit comments