@@ -24,11 +24,29 @@ class Store
2424 public function afterGetIdentities (\Magento \Store \Model \Store $ subject , array $ result ): array
2525 {
2626 $ result [] = sprintf ('%s_%s ' , ConfigIdentity::CACHE_TAG , $ subject ->getId ());
27- if ($ subject ->getOrigData ('is_active ' ) !== $ subject ->getIsActive () && $ subject ->getIsActive ()) {
27+ $ origStoreGroupId = $ subject ->getOrigData ('group_id ' );
28+ $ origIsActive = $ subject ->getOrigData ('is_active ' );
29+ // An existing active store switches store group
30+ if ($ origIsActive && $ origStoreGroupId != null && $ origStoreGroupId != $ subject ->getStoreGroupId ()) {
31+ $ origWebsiteId = $ subject ->getOrigData ('website_id ' );
32+ $ result [] = sprintf ('%s_%s ' , ConfigIdentity::CACHE_TAG , 'website_ ' . $ origWebsiteId );
33+ $ result [] = sprintf (
34+ '%s_%s ' ,
35+ ConfigIdentity::CACHE_TAG ,
36+ 'website_ ' . $ origWebsiteId . 'group_ ' . $ origStoreGroupId
37+ );
38+ }
39+ // New active store or newly activated store or an active store switched store group
40+ $ storeGroupId = $ subject ->getStoreGroupId ();
41+ $ isActive = $ subject ->getIsActive ();
42+ if ($ isActive && (
43+ $ subject ->getOrigData ('is_active ' ) !== $ isActive
44+ || ($ origStoreGroupId != null && $ origStoreGroupId != $ storeGroupId )
45+ )
46+ ) {
2847 $ websiteId = $ subject ->getWebsiteId ();
2948 if ($ websiteId !== null ) {
3049 $ result [] = sprintf ('%s_%s ' , ConfigIdentity::CACHE_TAG , 'website_ ' . $ websiteId );
31- $ storeGroupId = $ subject ->getStoreGroupId ();
3250 if ($ storeGroupId !== null ) {
3351 $ result [] = sprintf (
3452 '%s_%s ' ,
@@ -37,7 +55,6 @@ public function afterGetIdentities(\Magento\Store\Model\Store $subject, array $r
3755 );
3856 }
3957 }
40-
4158 }
4259
4360 return $ result ;
0 commit comments