Skip to content

Commit

Permalink
Fix multiple issues with object _hasDataChanges flag being set to tru…
Browse files Browse the repository at this point in the history
…e when there are no material changes to data. Fixes #1306
  • Loading branch information
colinmollenhour committed May 4, 2022
1 parent 19cd891 commit 88581cc
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 16 deletions.
34 changes: 31 additions & 3 deletions app/code/core/Mage/Catalog/Model/Product.php
Expand Up @@ -223,9 +223,6 @@
* @method $this setStoreId(int $store)
* @method bool hasStoreIds()
* @method $this setStoreIds(array $storeIds)
* @method Mage_CatalogInventory_Model_Stock_Item getStockItem()
* @method bool hasStockItem()
* @method $this setStockItem(Mage_CatalogInventory_Model_Stock_Item $value)
* @method array getSwatchPrices()
*
* @method int getTaxClassId()
Expand Down Expand Up @@ -344,6 +341,11 @@ class Mage_Catalog_Model_Product extends Mage_Catalog_Model_Abstract
*/
protected $_calculatePrice = true;

/**
* @var Mage_CatalogInventory_Model_Stock_Item
*/
protected $_stockItem;

/**
* Initialize resources
*/
Expand Down Expand Up @@ -694,6 +696,32 @@ public function getAttributes($groupId = null, $skipSuper = false)
return $attributes;
}

/**
* @return Mage_CatalogInventory_Model_Stock_Item
*/
public function getStockItem()
{
return $this->_stockItem;
}

/**
* @return bool
*/
public function hasStockItem()
{
return !!$this->_stockItem;
}

/**
* @param Mage_CatalogInventory_Model_Stock_Item $stockItem
* @return $this
*/
public function setStockItem(Mage_CatalogInventory_Model_Stock_Item $stockItem)
{
$this->_stockItem = $stockItem;
return $this;
}

/**
* Check product options and type options and save them, too
*
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Customer/Model/Address.php
Expand Up @@ -97,7 +97,9 @@ public function getCustomer()
public function setCustomer(Mage_Customer_Model_Customer $customer)
{
$this->_customer = $customer;
$this->setCustomerId($customer->getId());
if ($this->getCustomerId() != $customer->getId()) {
$this->setCustomerId($customer->getId());
}
return $this;
}

Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php
Expand Up @@ -176,7 +176,9 @@ public function getCreditmemo()
public function setOrderItem(Mage_Sales_Model_Order_Item $item)
{
$this->_orderItem = $item;
$this->setOrderItemId($item->getId());
if ($this->getOrderItemId() != $item->getId()) {
$this->setOrderItemId($item->getId());
}
return $this;
}

Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Sales/Model/Order/Invoice/Item.php
Expand Up @@ -159,7 +159,9 @@ public function getInvoice()
public function setOrderItem(Mage_Sales_Model_Order_Item $item)
{
$this->_orderItem = $item;
$this->setOrderItemId($item->getId());
if ($this->getOrderItemId() != $item->getId()) {
$this->setOrderItemId($item->getId());
}
return $this;
}

Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Sales/Model/Order/Item.php
Expand Up @@ -440,7 +440,9 @@ public function getQtyToCancelBundleItem()
public function setOrder(Mage_Sales_Model_Order $order)
{
$this->_order = $order;
$this->setOrderId($order->getId());
if ($this->getOrderId() != $order->getId()) {
$this->setOrderId($order->getId());
}
return $this;
}

Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Sales/Model/Order/Shipment/Item.php
Expand Up @@ -104,7 +104,9 @@ public function getShipment()
public function setOrderItem(Mage_Sales_Model_Order_Item $item)
{
$this->_orderItem = $item;
$this->setOrderItemId($item->getId());
if ($this->getOrderItemId() != $item->getId()) {
$this->setOrderItemId($item->getId());
}
return $this;
}

Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Sales/Model/Quote.php
Expand Up @@ -297,7 +297,9 @@ public function getStore()
*/
public function setStore(Mage_Core_Model_Store $store)
{
$this->setStoreId($store->getId());
if ($this->getStoreId() != $store->getId()) {
$this->setStoreId($store->getId());
}
return $this;
}

Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Sales/Model/Quote/Address.php
Expand Up @@ -427,7 +427,9 @@ protected function _afterSave()
public function setQuote(Mage_Sales_Model_Quote $quote)
{
$this->_quote = $quote;
$this->setQuoteId($quote->getId());
if ($this->getQuoteId() != $quote->getId()) {
$this->setQuoteId($quote->getId());
}
return $this;
}

Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Sales/Model/Quote/Item.php
Expand Up @@ -275,7 +275,9 @@ protected function _beforeSave()
public function setQuote(Mage_Sales_Model_Quote $quote)
{
$this->_quote = $quote;
$this->setQuoteId($quote->getId());
if ($this->getQuoteId() != $quote->getId()) {
$this->setQuoteId($quote->getId());
}
return $this;
}

Expand Down
8 changes: 6 additions & 2 deletions app/code/core/Mage/Sales/Model/Quote/Item/Option.php
Expand Up @@ -83,8 +83,10 @@ protected function _hasModelChanged()
*/
public function setItem($item)
{
$this->setItemId($item->getId());
$this->_item = $item;
if ($this->getItemId() != $item->getId()) {
$this->setItemId($item->getId());
}
return $this;
}

Expand All @@ -106,8 +108,10 @@ public function getItem()
*/
public function setProduct($product)
{
$this->setProductId($product->getId());
$this->_product = $product;
if ($this->getProductId() != $product->getId()) {
$this->setProductId($product->getId());
}
return $this;
}

Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Sales/Model/Quote/Payment.php
Expand Up @@ -119,7 +119,9 @@ protected function _construct()
public function setQuote(Mage_Sales_Model_Quote $quote)
{
$this->_quote = $quote;
$this->setQuoteId($quote->getId());
if ($this->getQuoteId() != $quote->getId()) {
$this->setQuoteId($quote->getId());
}
return $this;
}

Expand Down
9 changes: 7 additions & 2 deletions app/code/core/Mage/Wishlist/Model/Item/Option.php
Expand Up @@ -36,6 +36,7 @@
* @method int getProductId()
* @method $this setProductId(int $value)
* @method $this setWishlistItemId(int $value)
* @method int getWishlistItemId()
* @method $this setValue(string $sBuyRequest)
*/
class Mage_Wishlist_Model_Item_Option extends Mage_Core_Model_Abstract implements Mage_Catalog_Model_Product_Configuration_Item_Option_Interface
Expand Down Expand Up @@ -73,8 +74,10 @@ protected function _hasModelChanged()
*/
public function setItem($item)
{
$this->setWishlistItemId($item->getId());
$this->_item = $item;
if ($this->getWishlistItemId() != $item->getId()) {
$this->setWishlistItemId($item->getId());
}
return $this;
}

Expand All @@ -96,8 +99,10 @@ public function getItem()
*/
public function setProduct($product)
{
$this->setProductId($product->getId());
$this->_product = $product;
if ($this->getProductId() != $product->getId()) {
$this->setProductId($product->getId());
}
return $this;
}

Expand Down

0 comments on commit 88581cc

Please sign in to comment.