[FIX] website_sale: fix product grid not updating

This commit fixes the product image grid not being updated after
changing a variant.

TaskId-2922057

closes odoo/odoo#96102

Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
This commit is contained in:
William Braeckman
2022-07-18 18:41:46 +02:00
parent 920b25f5e7
commit b06a2ace32
@@ -496,22 +496,27 @@ publicWidget.registry.WebsiteSale = publicWidget.Widget.extend(VariantMixin, car
* @override
* @private
*/
_updateProductImage: function ($productContainer, displayImage, productId, productTemplateId, newCarousel, isCombinationPossible) {
var $carousel = $productContainer.find('#o-carousel-product');
_updateProductImage: function ($productContainer, displayImage, productId, productTemplateId, newImages, isCombinationPossible) {
let $images = $productContainer.find('#o-carousel-product');
if (!$images.length) {
$images = $productContainer.find("#o-grid-product");
}
// When using the web editor, don't reload this or the images won't
// be able to be edited depending on if this is done loading before
// or after the editor is ready.
if (window.location.search.indexOf('enable_editor') === -1) {
var $newCarousel = $(newCarousel);
$carousel.after($newCarousel);
$carousel.remove();
$carousel = $newCarousel;
$carousel.carousel(0);
if ($images.length && window.location.search.indexOf('enable_editor') === -1) {
const $newImages = $(newImages);
$images.after($newImages);
$images.remove();
$images = $newImages;
if ($images.attr('id') === 'o-carousel-product') {
$images.carousel(0);
}
this._startZoom();
// fix issue with carousel height
this.trigger_up('widgets_start_request', {$target: $carousel});
this.trigger_up('widgets_start_request', {$target: $images});
}
$carousel.toggleClass('css_not_available', !isCombinationPossible);
$images.toggleClass('css_not_available', !isCombinationPossible);
},
/**
* @private