@@ -27,7 +27,7 @@ public function afterGetIdentities(\Magento\Store\Model\Store $subject, array $r
27
27
$ origStoreGroupId = $ subject ->getOrigData ('group_id ' );
28
28
$ origIsActive = $ subject ->getOrigData ('is_active ' );
29
29
// An existing active store switches store group
30
- if ($ origIsActive && $ origStoreGroupId != null && $ origStoreGroupId != $ subject -> getStoreGroupId ( )) {
30
+ if ($ origIsActive && $ this -> isStoreGroupSwitched ( $ subject )) {
31
31
$ origWebsiteId = $ subject ->getOrigData ('website_id ' );
32
32
$ result [] = sprintf ('%s_%s ' , ConfigIdentity::CACHE_TAG , 'website_ ' . $ origWebsiteId );
33
33
$ result [] = sprintf (
@@ -36,13 +36,12 @@ public function afterGetIdentities(\Magento\Store\Model\Store $subject, array $r
36
36
'website_ ' . $ origWebsiteId . 'group_ ' . $ origStoreGroupId
37
37
);
38
38
}
39
+
39
40
// New active store or newly activated store or an active store switched store group
40
41
$ storeGroupId = $ subject ->getStoreGroupId ();
41
42
$ isActive = $ subject ->getIsActive ();
42
- if ($ isActive && (
43
- $ subject ->getOrigData ('is_active ' ) !== $ isActive
44
- || ($ origStoreGroupId != null && $ origStoreGroupId != $ storeGroupId )
45
- )
43
+ if ($ isActive
44
+ && ($ subject ->getOrigData ('is_active ' ) !== $ isActive || $ this ->isStoreGroupSwitched ($ subject ))
46
45
) {
47
46
$ websiteId = $ subject ->getWebsiteId ();
48
47
if ($ websiteId !== null ) {
@@ -59,4 +58,17 @@ public function afterGetIdentities(\Magento\Store\Model\Store $subject, array $r
59
58
60
59
return $ result ;
61
60
}
61
+
62
+ /**
63
+ * Check whether the store group of the store is switched
64
+ *
65
+ * @param \Magento\Store\Model\Store $store
66
+ * @return bool
67
+ */
68
+ private function isStoreGroupSwitched (\Magento \Store \Model \Store $ store ): bool
69
+ {
70
+ $ origStoreGroupId = $ store ->getOrigData ('group_id ' );
71
+ $ storeGroupId = $ store ->getStoreGroupId ();
72
+ return $ origStoreGroupId != null && $ origStoreGroupId != $ storeGroupId ;
73
+ }
62
74
}
0 commit comments