File tree Expand file tree Collapse file tree 1 file changed +19
-8
lines changed
app/code/Magento/Ui/Controller/Adminhtml/Bookmark Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -246,17 +246,28 @@ private function updateCurrentBookmarkConfig(array $data): void
246
246
$ bookmarkConfig = $ bookmark ->getConfig ();
247
247
$ existingConfig = $ bookmarkConfig ['views ' ][$ bookmark ->getIdentifier ()]['data ' ] ?? null ;
248
248
$ currentConfig = $ data [self ::CURRENT_IDENTIFIER ] ?? null ;
249
- if ($ existingConfig && $ currentConfig ) {
250
- if ($ existingConfig ['filters ' ] === $ currentConfig ['filters ' ]
251
- && $ existingConfig ['positions ' ] !== $ currentConfig ['positions ' ]
252
- ) {
253
- $ bookmarkConfig ['views ' ][$ bookmark ->getIdentifier ()]['data ' ] = $ data [self ::CURRENT_IDENTIFIER ];
254
- $ bookmark ->setConfig ($ this ->serializer ->serialize ($ bookmarkConfig ));
255
- $ this ->bookmarkRepository ->save ($ bookmark );
256
- }
249
+ if ($ existingConfig && $ currentConfig && $ this ->isPositionChanged ($ existingConfig , $ currentConfig )) {
250
+ $ bookmarkConfig ['views ' ][$ bookmark ->getIdentifier ()]['data ' ] = $ data [self ::CURRENT_IDENTIFIER ];
251
+ $ bookmark ->setConfig ($ this ->serializer ->serialize ($ bookmarkConfig ));
252
+ $ this ->bookmarkRepository ->save ($ bookmark );
257
253
}
258
254
break ;
259
255
}
260
256
}
261
257
}
258
+
259
+ /**
260
+ * Check if the positions for identical filters has changed
261
+ */
262
+ private function isPositionChanged (array $ existingConfig , array $ currentConfig ): bool
263
+ {
264
+ foreach (['filters ' , 'positions ' ] as $ key ) {
265
+ if (!array_key_exists ($ key , $ existingConfig ) || !array_key_exists ($ key , $ currentConfig )) {
266
+ return false ;
267
+ }
268
+ }
269
+
270
+ return $ existingConfig ['filters ' ] === $ currentConfig ['filters ' ]
271
+ && $ existingConfig ['positions ' ] !== $ currentConfig ['positions ' ];
272
+ }
262
273
}
You can’t perform that action at this time.
0 commit comments