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
18 changes: 16 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,14 @@ define([
}

imagesToUpdate = this._setImageIndex(imagesToUpdate);
gallery.updateData(imagesToUpdate);
if (gallery === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such check is not correct, please use typeof instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update the code.
Please review It.

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 +1241,14 @@ define([
});
}

gallery.first();
if (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