File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
app/code/Magento/CatalogGraphQl/Observer Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 12
12
use Magento \Framework \Event \ObserverInterface ;
13
13
use Magento \GraphQlResolverCache \Model \Resolver \Result \Type as GraphQlResolverCache ;
14
14
15
+ /**
16
+ * Clean media gallery resolver cache for product SKUs after importing data to database
17
+ */
15
18
class AfterImportDataObserver implements ObserverInterface
16
19
{
17
20
/**
@@ -34,23 +37,25 @@ public function execute(Observer $observer)
34
37
{
35
38
$ mediaGalleryEntriesChanged = $ observer ->getEvent ()->getMediaGallery ();
36
39
40
+ if (empty ($ mediaGalleryEntriesChanged )) {
41
+ return ;
42
+ }
43
+
37
44
$ productSkusToInvalidate = [];
38
45
39
46
foreach ($ mediaGalleryEntriesChanged as $ productSkus ) {
40
47
$ productSkusToInvalidate [] = array_keys ($ productSkus );
41
48
}
42
49
43
- $ productSkusToInvalidate = array_merge ([], ...$ productSkusToInvalidate );
50
+ $ productSkusToInvalidate = array_merge (...$ productSkusToInvalidate );
44
51
45
52
$ tags = array_map (function ($ productSku ) {
46
53
return sprintf ('%s_%s ' , ResolverCacheIdentity::CACHE_TAG , $ productSku );
47
54
}, $ productSkusToInvalidate );
48
55
49
- if (!empty ($ tags )) {
50
- $ this ->graphQlResolverCache ->clean (
51
- \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG ,
52
- $ tags
53
- );
54
- }
56
+ $ this ->graphQlResolverCache ->clean (
57
+ \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG ,
58
+ $ tags
59
+ );
55
60
}
56
61
}
You can’t perform that action at this time.
0 commit comments