@@ -126,10 +126,10 @@ public function save()
126
126
127
127
$ oldConfig = $ this ->_getConfig (true );
128
128
129
- $ deleteTransaction = $ this ->_transactionFactory ->create ();
130
129
/* @var $deleteTransaction \Magento\Framework\DB\Transaction */
131
- $ saveTransaction = $ this ->_transactionFactory ->create ();
130
+ $ deleteTransaction = $ this ->_transactionFactory ->create ();
132
131
/* @var $saveTransaction \Magento\Framework\DB\Transaction */
132
+ $ saveTransaction = $ this ->_transactionFactory ->create ();
133
133
134
134
$ changedPaths = [];
135
135
// Extends for old config data
@@ -144,9 +144,20 @@ public function save()
144
144
$ extraOldGroups ,
145
145
$ oldConfig ,
146
146
$ saveTransaction ,
147
- $ deleteTransaction ,
148
- $ changedPaths
147
+ $ deleteTransaction
149
148
);
149
+
150
+ if (isset ($ groupData ['fields ' ])) {
151
+ $ groupPath = $ sectionId . '/ ' . $ groupId ;
152
+ foreach ($ groupData ['fields ' ] as $ fieldId => $ fieldData ) {
153
+ /** @var $field \Magento\Config\Model\Config\Structure\Element\Field */
154
+ $ field = $ this ->_configStructure ->getElement ($ groupPath . '/ ' . $ fieldId );
155
+ $ path = $ field ->getGroupPath () . '/ ' . $ fieldId ;
156
+ if ($ this ->isValueChanged ($ oldConfig , $ path , $ fieldData )) {
157
+ $ changedPaths [] = $ path ;
158
+ }
159
+ }
160
+ }
150
161
}
151
162
152
163
try {
@@ -174,6 +185,25 @@ public function save()
174
185
return $ this ;
175
186
}
176
187
188
+ /**
189
+ * Check is config value changed
190
+ *
191
+ * @param array $oldConfig
192
+ * @param string $path
193
+ * @param array $fieldData
194
+ * @return bool
195
+ */
196
+ private function isValueChanged (array $ oldConfig , string $ path , array $ fieldData )
197
+ {
198
+ if (isset ($ oldConfig [$ path ]['value ' ])) {
199
+ $ result = !isset ($ fieldData ['value ' ]) || $ oldConfig [$ path ]['value ' ] !== $ fieldData ['value ' ];
200
+ } else {
201
+ $ result = empty ($ fieldData ['inherit ' ]);
202
+ }
203
+
204
+ return $ result ;
205
+ }
206
+
177
207
/**
178
208
* Process group data
179
209
*
@@ -185,7 +215,6 @@ public function save()
185
215
* @param array &$oldConfig
186
216
* @param \Magento\Framework\DB\Transaction $saveTransaction
187
217
* @param \Magento\Framework\DB\Transaction $deleteTransaction
188
- * @param array &$changedPaths
189
218
* @return void
190
219
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
191
220
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -199,8 +228,7 @@ protected function _processGroup(
199
228
array &$ extraOldGroups ,
200
229
array &$ oldConfig ,
201
230
\Magento \Framework \DB \Transaction $ saveTransaction ,
202
- \Magento \Framework \DB \Transaction $ deleteTransaction ,
203
- array &$ changedPaths = []
231
+ \Magento \Framework \DB \Transaction $ deleteTransaction
204
232
) {
205
233
$ groupPath = $ sectionPath . '/ ' . $ groupId ;
206
234
$ scope = $ this ->getScope ();
@@ -300,13 +328,9 @@ protected function _processGroup(
300
328
} else {
301
329
$ deleteTransaction ->addObject ($ backendModel );
302
330
}
303
- if ($ oldConfig [$ path ]['value ' ] !== $ fieldData ['value ' ]) {
304
- $ changedPaths [] = $ path ;
305
- }
306
331
} elseif (!$ inherit ) {
307
332
$ backendModel ->unsConfigId ();
308
333
$ saveTransaction ->addObject ($ backendModel );
309
- $ changedPaths [] = $ path ;
310
334
}
311
335
}
312
336
}
@@ -321,8 +345,7 @@ protected function _processGroup(
321
345
$ extraOldGroups ,
322
346
$ oldConfig ,
323
347
$ saveTransaction ,
324
- $ deleteTransaction ,
325
- $ changedPaths
348
+ $ deleteTransaction
326
349
);
327
350
}
328
351
}
0 commit comments