Skip to content

Commit

Permalink
Merge pull request #145 from matesich/gallery-issue
Browse files Browse the repository at this point in the history
fixed emulation issue for media gallery entries
  • Loading branch information
AleksandrsKondratjevs authored Dec 27, 2022
2 parents ebd1ad3 + 8c1abb3 commit c035e13
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Model/Resolver/Product/MediaGalleryEntries.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ protected function getImageOfType(
$imageId,
$type
) {
$storeId = $this->storeManager->getStore()->getId();
$this->emulation->startEnvironmentEmulation($storeId, Area::AREA_FRONTEND, true);

$image = $this->helperFactory->init($mediaGalleryEntry, $imageId, ['type' => $type])
->setImageFile($mediaGalleryEntry->getData('file'))
->constrainOnly(true)
Expand All @@ -83,8 +80,6 @@ protected function getImageOfType(

$url = $image->getUrl();

$this->emulation->stopEnvironmentEmulation();

return [
'url' => $url,
'type' => $type
Expand Down Expand Up @@ -116,6 +111,9 @@ public function resolve(
$mediaGalleryEntries = [];

if (!empty($product->getMediaGalleryEntries())) {
$storeId = $this->storeManager->getStore()->getId();
$this->emulation->startEnvironmentEmulation($storeId, Area::AREA_FRONTEND, true);

foreach ($product->getMediaGalleryEntries() as $key => $entry) {
$thumbnail = $this->getImageOfType($entry, 'scandipwa_media_thumbnail', 'thumbnail');
$base = $this->getImageOfType($entry, 'scandipwa_media_base', 'small_image');
Expand All @@ -127,6 +125,8 @@ public function resolve(
= $entry->getExtensionAttributes()->getVideoContent()->getData();
}
}

$this->emulation->stopEnvironmentEmulation();
}

$result = function () use ($mediaGalleryEntries) {
Expand Down

0 comments on commit c035e13

Please sign in to comment.