Skip to content

Commit 88581cc

Browse files
Fix multiple issues with object _hasDataChanges flag being set to true when there are no material changes to data. Fixes #1306
1 parent 19cd891 commit 88581cc

File tree

12 files changed

+71
-16
lines changed

12 files changed

+71
-16
lines changed

app/code/core/Mage/Catalog/Model/Product.php

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@
223223
* @method $this setStoreId(int $store)
224224
* @method bool hasStoreIds()
225225
* @method $this setStoreIds(array $storeIds)
226-
* @method Mage_CatalogInventory_Model_Stock_Item getStockItem()
227-
* @method bool hasStockItem()
228-
* @method $this setStockItem(Mage_CatalogInventory_Model_Stock_Item $value)
229226
* @method array getSwatchPrices()
230227
*
231228
* @method int getTaxClassId()
@@ -344,6 +341,11 @@ class Mage_Catalog_Model_Product extends Mage_Catalog_Model_Abstract
344341
*/
345342
protected $_calculatePrice = true;
346343

344+
/**
345+
* @var Mage_CatalogInventory_Model_Stock_Item
346+
*/
347+
protected $_stockItem;
348+
347349
/**
348350
* Initialize resources
349351
*/
@@ -694,6 +696,32 @@ public function getAttributes($groupId = null, $skipSuper = false)
694696
return $attributes;
695697
}
696698

699+
/**
700+
* @return Mage_CatalogInventory_Model_Stock_Item
701+
*/
702+
public function getStockItem()
703+
{
704+
return $this->_stockItem;
705+
}
706+
707+
/**
708+
* @return bool
709+
*/
710+
public function hasStockItem()
711+
{
712+
return !!$this->_stockItem;
713+
}
714+
715+
/**
716+
* @param Mage_CatalogInventory_Model_Stock_Item $stockItem
717+
* @return $this
718+
*/
719+
public function setStockItem(Mage_CatalogInventory_Model_Stock_Item $stockItem)
720+
{
721+
$this->_stockItem = $stockItem;
722+
return $this;
723+
}
724+
697725
/**
698726
* Check product options and type options and save them, too
699727
*

app/code/core/Mage/Customer/Model/Address.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ public function getCustomer()
9797
public function setCustomer(Mage_Customer_Model_Customer $customer)
9898
{
9999
$this->_customer = $customer;
100-
$this->setCustomerId($customer->getId());
100+
if ($this->getCustomerId() != $customer->getId()) {
101+
$this->setCustomerId($customer->getId());
102+
}
101103
return $this;
102104
}
103105

app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ public function getCreditmemo()
176176
public function setOrderItem(Mage_Sales_Model_Order_Item $item)
177177
{
178178
$this->_orderItem = $item;
179-
$this->setOrderItemId($item->getId());
179+
if ($this->getOrderItemId() != $item->getId()) {
180+
$this->setOrderItemId($item->getId());
181+
}
180182
return $this;
181183
}
182184

app/code/core/Mage/Sales/Model/Order/Invoice/Item.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ public function getInvoice()
159159
public function setOrderItem(Mage_Sales_Model_Order_Item $item)
160160
{
161161
$this->_orderItem = $item;
162-
$this->setOrderItemId($item->getId());
162+
if ($this->getOrderItemId() != $item->getId()) {
163+
$this->setOrderItemId($item->getId());
164+
}
163165
return $this;
164166
}
165167

app/code/core/Mage/Sales/Model/Order/Item.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,9 @@ public function getQtyToCancelBundleItem()
440440
public function setOrder(Mage_Sales_Model_Order $order)
441441
{
442442
$this->_order = $order;
443-
$this->setOrderId($order->getId());
443+
if ($this->getOrderId() != $order->getId()) {
444+
$this->setOrderId($order->getId());
445+
}
444446
return $this;
445447
}
446448

app/code/core/Mage/Sales/Model/Order/Shipment/Item.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ public function getShipment()
104104
public function setOrderItem(Mage_Sales_Model_Order_Item $item)
105105
{
106106
$this->_orderItem = $item;
107-
$this->setOrderItemId($item->getId());
107+
if ($this->getOrderItemId() != $item->getId()) {
108+
$this->setOrderItemId($item->getId());
109+
}
108110
return $this;
109111
}
110112

app/code/core/Mage/Sales/Model/Quote.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@ public function getStore()
297297
*/
298298
public function setStore(Mage_Core_Model_Store $store)
299299
{
300-
$this->setStoreId($store->getId());
300+
if ($this->getStoreId() != $store->getId()) {
301+
$this->setStoreId($store->getId());
302+
}
301303
return $this;
302304
}
303305

app/code/core/Mage/Sales/Model/Quote/Address.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,9 @@ protected function _afterSave()
427427
public function setQuote(Mage_Sales_Model_Quote $quote)
428428
{
429429
$this->_quote = $quote;
430-
$this->setQuoteId($quote->getId());
430+
if ($this->getQuoteId() != $quote->getId()) {
431+
$this->setQuoteId($quote->getId());
432+
}
431433
return $this;
432434
}
433435

app/code/core/Mage/Sales/Model/Quote/Item.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ protected function _beforeSave()
275275
public function setQuote(Mage_Sales_Model_Quote $quote)
276276
{
277277
$this->_quote = $quote;
278-
$this->setQuoteId($quote->getId());
278+
if ($this->getQuoteId() != $quote->getId()) {
279+
$this->setQuoteId($quote->getId());
280+
}
279281
return $this;
280282
}
281283

app/code/core/Mage/Sales/Model/Quote/Item/Option.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ protected function _hasModelChanged()
8383
*/
8484
public function setItem($item)
8585
{
86-
$this->setItemId($item->getId());
8786
$this->_item = $item;
87+
if ($this->getItemId() != $item->getId()) {
88+
$this->setItemId($item->getId());
89+
}
8890
return $this;
8991
}
9092

@@ -106,8 +108,10 @@ public function getItem()
106108
*/
107109
public function setProduct($product)
108110
{
109-
$this->setProductId($product->getId());
110111
$this->_product = $product;
112+
if ($this->getProductId() != $product->getId()) {
113+
$this->setProductId($product->getId());
114+
}
111115
return $this;
112116
}
113117

0 commit comments

Comments
 (0)