Skip to content

Commit c035e13

Browse files
Merge pull request #145 from matesich/gallery-issue
fixed emulation issue for media gallery entries
2 parents ebd1ad3 + 8c1abb3 commit c035e13

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Model/Resolver/Product/MediaGalleryEntries.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ protected function getImageOfType(
7171
$imageId,
7272
$type
7373
) {
74-
$storeId = $this->storeManager->getStore()->getId();
75-
$this->emulation->startEnvironmentEmulation($storeId, Area::AREA_FRONTEND, true);
76-
7774
$image = $this->helperFactory->init($mediaGalleryEntry, $imageId, ['type' => $type])
7875
->setImageFile($mediaGalleryEntry->getData('file'))
7976
->constrainOnly(true)
@@ -83,8 +80,6 @@ protected function getImageOfType(
8380

8481
$url = $image->getUrl();
8582

86-
$this->emulation->stopEnvironmentEmulation();
87-
8883
return [
8984
'url' => $url,
9085
'type' => $type
@@ -116,6 +111,9 @@ public function resolve(
116111
$mediaGalleryEntries = [];
117112

118113
if (!empty($product->getMediaGalleryEntries())) {
114+
$storeId = $this->storeManager->getStore()->getId();
115+
$this->emulation->startEnvironmentEmulation($storeId, Area::AREA_FRONTEND, true);
116+
119117
foreach ($product->getMediaGalleryEntries() as $key => $entry) {
120118
$thumbnail = $this->getImageOfType($entry, 'scandipwa_media_thumbnail', 'thumbnail');
121119
$base = $this->getImageOfType($entry, 'scandipwa_media_base', 'small_image');
@@ -127,6 +125,8 @@ public function resolve(
127125
= $entry->getExtensionAttributes()->getVideoContent()->getData();
128126
}
129127
}
128+
129+
$this->emulation->stopEnvironmentEmulation();
130130
}
131131

132132
$result = function () use ($mediaGalleryEntries) {

0 commit comments

Comments
 (0)