Skip to content

Commit 6f5b681

Browse files
MAGETWO-96593: Image Position issue with Associated Products
1 parent ff692d0 commit 6f5b681

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

app/code/Magento/Swatches/Helper/Data.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,14 @@ public function getProductMediaGallery(ModelProduct $product): array
332332
$baseImage = $mediaEntry->getFile();
333333
}
334334

335-
$gallery[$mediaEntry->getId()] = $this->collectImageData($mediaEntry);
335+
$gallery[$mediaEntry->getId()] = $this->collectImageData($product, $mediaEntry);
336336
}
337337

338338
if (!$baseImage) {
339339
return [];
340340
}
341341

342-
$resultGallery = $this->collectImageData($baseImage);
342+
$resultGallery = $this->collectImageData($product, $baseImage);
343343
$resultGallery['gallery'] = $gallery;
344344

345345
return $resultGallery;
@@ -359,14 +359,17 @@ private function isMainImage(ProductAttributeMediaGalleryEntryInterface $mediaEn
359359
/**
360360
* Returns image data for swatches
361361
*
362+
* @param ModelProduct $product
362363
* @param ProductAttributeMediaGalleryEntryInterface $mediaEntry
363364
* @return array
364365
*/
365-
private function collectImageData(ProductAttributeMediaGalleryEntryInterface $mediaEntry): array
366-
{
367-
$image = $this->getAllSizeImages($mediaEntry->getFile());
368-
$image[ProductAttributeMediaGalleryEntryInterface::POSITION] = $mediaEntry->getPosition();
369-
$image['isMain'] =$this->isMainImage($mediaEntry);
366+
private function collectImageData(
367+
ModelProduct $product,
368+
ProductAttributeMediaGalleryEntryInterface $mediaEntry
369+
): array {
370+
$image = $this->getAllSizeImages($product, $mediaEntry->getFile());
371+
$image[ProductAttributeMediaGalleryEntryInterface::POSITION] = $mediaEntry->getPosition();
372+
$image['isMain'] = $this->isMainImage($mediaEntry);
370373
return $image;
371374
}
372375

app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,10 +667,9 @@ define([
667667
/**
668668
* Load media gallery using ajax or json config.
669669
*
670-
* @param {String|undefined} eventName
671670
* @private
672671
*/
673-
_loadMedia: function (eventName) {
672+
_loadMedia: function () {
674673
var $main = this.inProductList ?
675674
this.element.parents('.product-item-info') :
676675
this.element.parents('.column.main'),

0 commit comments

Comments
 (0)