@@ -24,11 +24,29 @@ class Store
24
24
public function afterGetIdentities (\Magento \Store \Model \Store $ subject , array $ result ): array
25
25
{
26
26
$ 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
+ ) {
28
47
$ websiteId = $ subject ->getWebsiteId ();
29
48
if ($ websiteId !== null ) {
30
49
$ result [] = sprintf ('%s_%s ' , ConfigIdentity::CACHE_TAG , 'website_ ' . $ websiteId );
31
- $ storeGroupId = $ subject ->getStoreGroupId ();
32
50
if ($ storeGroupId !== null ) {
33
51
$ result [] = sprintf (
34
52
'%s_%s ' ,
@@ -37,7 +55,6 @@ public function afterGetIdentities(\Magento\Store\Model\Store $subject, array $r
37
55
);
38
56
}
39
57
}
40
-
41
58
}
42
59
43
60
return $ result ;
0 commit comments