-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
Reduce needless saves by avoiding setting _hasDataChanges flag #2066
Reduce needless saves by avoiding setting _hasDataChanges flag #2066
Conversation
Insta-like! |
since this is on v20 branch we should modify the README to add this PR to the "changes between v19 and v20" ;-) |
…e when there are no material changes to data. Fixes OpenMage#1306
88581cc
to
f1d7807
Compare
I added a note to README so it dismissed approvals from @fballiano and @kiatng |
*/ | ||
public function hasStockItem() | ||
{ | ||
return !!$this->_stockItem; |
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.
why there is a double negation?
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's a cast to boolean as far as I've read
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.
I never used it but it is the equivalent (bool) $variables
. Maybe the code with this variant !! should be modified to be more explicit for most and not to be able to search the Internet for the "double not" operator in PHP. A longer discussion exists here https://stackoverflow.com/questions/2127260/double-not-operator-in-php. Some people consider using it "fancy".
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.
Sorry, this is a habit from writing C.. In PHP probably better to just use (bool) but they are functionally equivalent.
By adding: public function setStockItem(Mage_CatalogInventory_Model_Stock_Item $stockItem) Sorry, but there is: magento-lts/app/code/core/Mage/CatalogInventory/Model/Stock/Status.php Lines 494 to 498 in 90fb732
And this produce:
|
I'll keep a tab with this PR open so that we don't forget about this problem... |
…hod and fix incorrect class instantiated in addStockStatusToProducts. Refs OpenMage#2066
Another side effect, with That produce: |
If we have a problem with this PR then it must be reported in Issues. |
No problem, but if another people encounter the same problem, I hope his preferred search engine will lead him here. |
In some cases a setter is called just to store a reference to an object and not actually update the model data but it causes the model to be considered dirty thereby causing needles model saves. This tackles specific instances of this occurring but there is also a more holistic approach proposed in #1306.
This implements alternative changes proposed in #1306 (comment) and also an alternative solution to #1307