-
-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed PR #523, prevent unnecessary saving of status history when orde… #2042
Fixed PR #523, prevent unnecessary saving of status history when orde… #2042
Conversation
…hen order is saved.
foreach ($this->_statusHistory as $status) { | ||
$status->setOrder($this); | ||
$status->setDataChanges(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems we need to add this setDataChanges calls in a lot of places, but doesn't it mean we should modify some Abstract or something like that to solve this issue in a more general way?
@fballiano is right, there should be a general way to solve this, but I have not found the way to do it. |
While the current change will work fine, I found that all collections suffer from this issue! This could be fixed in all places by applying the below patch to diff --git a/lib/Varien/Data/Collection/Db.php b/lib/Varien/Data/Collection/Db.php
index 147f25ca3d..ff85dcaada 100644
--- a/lib/Varien/Data/Collection/Db.php
+++ b/lib/Varien/Data/Collection/Db.php
@@ -587,6 +587,7 @@ class Varien_Data_Collection_Db extends Varien_Data_Collection
$item->setIdFieldName($this->getIdFieldName());
}
$item->addData($row);
+ $item->setDataChanges(false);
$this->addItem($item);
}
} What do you think? |
@elidrissidev It's a good idea. Can you create a PR and close this one? |
@kiatng Sure. Will do it as soon as I get some time. |
…r is saved.
Description (*)
Order is saved when comments are added in the backend. Before this PR, this will save the new comment (status history object) along with all the old status histories which are unnecessary. After this PR, only the new comment is saved.
Related Pull Requests
PR #523
Fixed Issues (if relevant)
Manual testing scenarios (*)
To test this, add test code in
app\code\core\Mage\Sales\Model\Order\Status\History.php
Test result before PR:
Test result after PR:
Questions or comments
Contribution checklist (*)