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)
122
122
}
123
123
return $ this ;
124
124
}
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
+ }
125
148
}
Original file line number Diff line number Diff line change 5
5
*/
6
6
namespace Magento \Framework \Model \ResourceModel \Db \VersionControl ;
7
7
8
+ use Magento \Framework \DataObject ;
8
9
use Magento \Framework \ObjectManager \ResetAfterRequestInterface ;
9
10
10
11
/**
@@ -50,6 +51,17 @@ public function registerSnapshot(\Magento\Framework\DataObject $entity)
50
51
$ this ->snapshotData [get_class ($ entity )][$ entity ->getId ()] = $ data ;
51
52
}
52
53
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
+
53
65
/**
54
66
* Check is current entity has changes, by comparing current object state with stored snapshot
55
67
*
@@ -67,15 +79,8 @@ public function isModified(\Magento\Framework\DataObject $entity)
67
79
return true ;
68
80
}
69
81
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 ;
79
84
}
80
85
}
81
86
You can’t perform that action at this time.
0 commit comments