@@ -27,7 +27,7 @@ public function afterGetIdentities(\Magento\Store\Model\Store $subject, array $r
2727 $ origStoreGroupId = $ subject ->getOrigData ('group_id ' );
2828 $ origIsActive = $ subject ->getOrigData ('is_active ' );
2929 // An existing active store switches store group
30- if ($ origIsActive && $ origStoreGroupId != null && $ origStoreGroupId != $ subject -> getStoreGroupId ( )) {
30+ if ($ origIsActive && $ this -> isStoreGroupSwitched ( $ subject )) {
3131 $ origWebsiteId = $ subject ->getOrigData ('website_id ' );
3232 $ result [] = sprintf ('%s_%s ' , ConfigIdentity::CACHE_TAG , 'website_ ' . $ origWebsiteId );
3333 $ result [] = sprintf (
@@ -36,13 +36,12 @@ public function afterGetIdentities(\Magento\Store\Model\Store $subject, array $r
3636 'website_ ' . $ origWebsiteId . 'group_ ' . $ origStoreGroupId
3737 );
3838 }
39+
3940 // New active store or newly activated store or an active store switched store group
4041 $ storeGroupId = $ subject ->getStoreGroupId ();
4142 $ 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 ))
4645 ) {
4746 $ websiteId = $ subject ->getWebsiteId ();
4847 if ($ websiteId !== null ) {
@@ -59,4 +58,17 @@ public function afterGetIdentities(\Magento\Store\Model\Store $subject, array $r
5958
6059 return $ result ;
6160 }
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+ }
6274}
0 commit comments