@@ -33,30 +33,33 @@ public function __construct(StoreManagerInterface $storeManager)
33
33
public function getIdentities (array $ resolvedData ): array
34
34
{
35
35
$ ids = [];
36
- $ storeGroups = [];
36
+ $ storeGroupIds = [];
37
37
$ store = null ;
38
+ $ storeGroupCount = 0 ;
38
39
foreach ($ resolvedData as $ storeConfig ) {
39
40
$ ids [] = sprintf ('%s_%s ' , StoreConfigIdentity::CACHE_TAG , $ storeConfig ['id ' ]);
40
- try {
41
- // Record store groups
42
- $ store = $ this ->storeManager ->getStore ($ storeConfig ['id ' ]);
43
- $ storeGroupId = $ store ->getStoreGroupId ();
44
- if ($ storeGroupId !== null ) {
45
- $ storeGroups [$ storeGroupId ] = true ;
41
+ if ($ storeGroupCount < 2 ) {
42
+ try {
43
+ // Record store groups
44
+ $ store = $ this ->storeManager ->getStore ($ storeConfig ['id ' ]);
45
+ $ storeGroupId = $ store ->getStoreGroupId ();
46
+ if ($ storeGroupId !== null && !in_array ($ storeGroupId , $ storeGroupIds )) {
47
+ $ storeGroupIds [] = $ storeGroupId ;
48
+ $ storeGroupCount ++;
49
+ }
50
+ } catch (NoSuchEntityException $ e ) {
51
+ // Do nothing
52
+ ;
46
53
}
47
- } catch (NoSuchEntityException $ e ) {
48
- // Do nothing
49
- ;
50
54
}
51
55
}
52
- $ storeGroupCount = count ($ storeGroups );
53
56
if ($ storeGroupCount > 1 ) { // the resolved stores for any store groups in a website
54
57
$ ids [] = sprintf ('%s_%s ' , StoreConfigIdentity::CACHE_TAG , 'website_ ' . $ store ->getWebsiteId ());
55
58
} elseif ($ storeGroupCount == 1 ) { // the resolved stores for a particular store group in a website
56
59
$ ids [] = sprintf (
57
60
'%s_%s ' ,
58
61
StoreConfigIdentity::CACHE_TAG ,
59
- 'website_ ' . $ store ->getWebsiteId () . 'group_ ' . array_keys ( $ storeGroups ) [0 ]
62
+ 'website_ ' . $ store ->getWebsiteId () . 'group_ ' . $ storeGroupIds [0 ]
60
63
);
61
64
}
62
65
0 commit comments