@@ -71,9 +71,6 @@ protected function getImageOfType(
71
71
$ imageId ,
72
72
$ type
73
73
) {
74
- $ storeId = $ this ->storeManager ->getStore ()->getId ();
75
- $ this ->emulation ->startEnvironmentEmulation ($ storeId , Area::AREA_FRONTEND , true );
76
-
77
74
$ image = $ this ->helperFactory ->init ($ mediaGalleryEntry , $ imageId , ['type ' => $ type ])
78
75
->setImageFile ($ mediaGalleryEntry ->getData ('file ' ))
79
76
->constrainOnly (true )
@@ -83,8 +80,6 @@ protected function getImageOfType(
83
80
84
81
$ url = $ image ->getUrl ();
85
82
86
- $ this ->emulation ->stopEnvironmentEmulation ();
87
-
88
83
return [
89
84
'url ' => $ url ,
90
85
'type ' => $ type
@@ -116,6 +111,9 @@ public function resolve(
116
111
$ mediaGalleryEntries = [];
117
112
118
113
if (!empty ($ product ->getMediaGalleryEntries ())) {
114
+ $ storeId = $ this ->storeManager ->getStore ()->getId ();
115
+ $ this ->emulation ->startEnvironmentEmulation ($ storeId , Area::AREA_FRONTEND , true );
116
+
119
117
foreach ($ product ->getMediaGalleryEntries () as $ key => $ entry ) {
120
118
$ thumbnail = $ this ->getImageOfType ($ entry , 'scandipwa_media_thumbnail ' , 'thumbnail ' );
121
119
$ base = $ this ->getImageOfType ($ entry , 'scandipwa_media_base ' , 'small_image ' );
@@ -127,6 +125,8 @@ public function resolve(
127
125
= $ entry ->getExtensionAttributes ()->getVideoContent ()->getData ();
128
126
}
129
127
}
128
+
129
+ $ this ->emulation ->stopEnvironmentEmulation ();
130
130
}
131
131
132
132
$ result = function () use ($ mediaGalleryEntries ) {
0 commit comments