File tree Expand file tree Collapse file tree 2 files changed +37
-9
lines changed
app/code/Magento/Sales/Model/ResourceModel/Order
lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl Expand file tree Collapse file tree 2 files changed +37
-9
lines changed Original file line number Diff line number Diff line change @@ -122,4 +122,27 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
122122 }
123123 return $ this ;
124124 }
125+
126+ /**
127+ * Check is current order address entity has changes, by comparing current object state with stored snapshot
128+ *
129+ * @param \Magento\Framework\DataObject $entity
130+ * @return bool
131+ */
132+ protected function isModified (\Magento \Framework \Model \AbstractModel $ entity )
133+ {
134+ if (!$ entity ->getId ()) {
135+ return true ;
136+ }
137+ $ snapChatData = $ this ->entitySnapshot ->getSnapshotData ($ entity );
138+ foreach ($ snapChatData as $ field => $ value ) {
139+ $ fieldValue = $ entity ->getDataByKey ($ field );
140+ if (is_numeric ($ fieldValue ) && is_numeric ($ value )) {
141+ if ($ fieldValue !== $ value ) {
142+ return true ;
143+ }
144+ }
145+ }
146+ return parent ::isModified ($ entity );
147+ }
125148}
Original file line number Diff line number Diff line change 55 */
66namespace Magento \Framework \Model \ResourceModel \Db \VersionControl ;
77
8+ use Magento \Framework \DataObject ;
89use Magento \Framework \ObjectManager \ResetAfterRequestInterface ;
910
1011/**
@@ -50,6 +51,17 @@ public function registerSnapshot(\Magento\Framework\DataObject $entity)
5051 $ this ->snapshotData [get_class ($ entity )][$ entity ->getId ()] = $ data ;
5152 }
5253
54+ /**
55+ * Get snapshot data
56+ *
57+ * @param DataObject $entity
58+ * @return array
59+ */
60+ public function getSnapshotData (\Magento \Framework \DataObject $ entity )
61+ {
62+ return $ this ->snapshotData [get_class ($ entity )][$ entity ->getId ()];
63+ }
64+
5365 /**
5466 * Check is current entity has changes, by comparing current object state with stored snapshot
5567 *
@@ -67,15 +79,8 @@ public function isModified(\Magento\Framework\DataObject $entity)
6779 return true ;
6880 }
6981 foreach ($ this ->snapshotData [$ entityClass ][$ entity ->getId ()] as $ field => $ value ) {
70- $ fieldValue = $ entity ->getDataByKey ($ field );
71- if (is_numeric ($ fieldValue ) && is_numeric ($ value )) {
72- if ($ fieldValue !== $ value ) {
73- return true ;
74- }
75- } else {
76- if ($ fieldValue != $ value ) {
77- return true ;
78- }
82+ if ($ entity ->getDataByKey ($ field ) != $ value ) {
83+ return true ;
7984 }
8085 }
8186
You can’t perform that action at this time.
0 commit comments