@@ -39,11 +39,11 @@ public function __construct(
39
39
/**
40
40
* Register snapshot of entity data, for tracking changes
41
41
*
42
- * @param \Magento\Framework\ DataObject $entity
42
+ * @param DataObject $entity
43
43
* @return void
44
44
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
45
45
*/
46
- public function registerSnapshot (\ Magento \ Framework \ DataObject $ entity )
46
+ public function registerSnapshot (DataObject $ entity )
47
47
{
48
48
$ metaData = $ this ->metadata ->getFields ($ entity );
49
49
$ filteredData = array_intersect_key ($ entity ->getData (), $ metaData );
@@ -72,10 +72,10 @@ public function getSnapshotData(DataObject $entity): array
72
72
/**
73
73
* Check is current entity has changes, by comparing current object state with stored snapshot
74
74
*
75
- * @param \Magento\Framework\ DataObject $entity
75
+ * @param DataObject $entity
76
76
* @return bool
77
77
*/
78
- public function isModified (\ Magento \ Framework \ DataObject $ entity )
78
+ public function isModified (DataObject $ entity ): bool
79
79
{
80
80
if (!$ entity ->getId ()) {
81
81
return true ;
@@ -86,7 +86,14 @@ public function isModified(\Magento\Framework\DataObject $entity)
86
86
return true ;
87
87
}
88
88
foreach ($ this ->snapshotData [$ entityClass ][$ entity ->getId ()] as $ field => $ value ) {
89
- if ($ entity ->getDataByKey ($ field ) != $ value ) {
89
+ $ entityValue = $ entity ->getDataByKey ($ field );
90
+ if (is_array ($ entityValue ) && is_string ($ value )) {
91
+ $ decodedValue = json_decode ($ value , true );
92
+ if (json_last_error () === JSON_ERROR_NONE ) {
93
+ $ value = $ decodedValue ;
94
+ }
95
+ }
96
+ if ($ entityValue != $ value ) {
90
97
return true ;
91
98
}
92
99
}
@@ -97,9 +104,9 @@ public function isModified(\Magento\Framework\DataObject $entity)
97
104
/**
98
105
* Clear snapshot data
99
106
*
100
- * @param \Magento\Framework\ DataObject|null $entity
107
+ * @param DataObject|null $entity
101
108
*/
102
- public function clear (\ Magento \ Framework \ DataObject $ entity = null )
109
+ public function clear (DataObject $ entity = null )
103
110
{
104
111
if ($ entity !== null ) {
105
112
$ this ->snapshotData [get_class ($ entity )] = [];
0 commit comments