Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 18017 magento 23 #19635

Merged
19 changes: 17 additions & 2 deletions app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,15 @@ define([
}

imagesToUpdate = this._setImageIndex(imagesToUpdate);
gallery.updateData(imagesToUpdate);

if (typeof gallery === undefined) {
context.find(this.options.mediaGallerySelector).on('gallery:loaded', function (loadedGallery) {
loadedGallery = context.find(this.options.mediaGallerySelector).data('gallery');
loadedGallery.updateData(imagesToUpdate);
}.bind(this));
} else {
gallery.updateData(imagesToUpdate);
}

if (isInitial) {
$(this.options.mediaGallerySelector).AddFotoramaVideoEvents();
Expand All @@ -1234,7 +1242,14 @@ define([
});
}

gallery.first();
if (typeof gallery === undefined) {
context.find(this.options.mediaGallerySelector).on('gallery:loaded', function (loadedGallery) {
loadedGallery = context.find(this.options.mediaGallerySelector).data('gallery');
loadedGallery.first();
}.bind(this));
} else {
gallery.first();
}

} else if (justAnImage && justAnImage.img) {
context.find('.product-image-photo').attr('src', justAnImage.img);
Expand Down