[FIX] website_sale: unify image update when change variant
The variants on a product in the ecommerce can appear: - naturally, not a list, colored square for color, ... - in a list of radio button. To have the second kind, we need to enable the "List View of Variants" customize option. One part of the code was not the same which cause an issue when saving the image of the variant, it was saved on the product.template instead. This commit add an "update_product_image" function which is now called in both scenario. first half of: opw-654279 forward port note: in 9.0 website/image -> web/image
This commit is contained in:
parent
15b0596c31
commit
a8ae94485d
|
@ -1,4 +1,12 @@
|
|||
$(document).ready(function () {
|
||||
|
||||
function update_product_image(event_source, product_id) {
|
||||
var $img = $(event_source).closest('tr.js_product, .oe_website_sale').find('span[data-oe-model^="product."][data-oe-type="image"] img:first, img.product_detail_img');
|
||||
$img.attr("src", "/website/image/product.product/" + product_id + "/image");
|
||||
$img.parent().attr('data-oe-model', 'product.product').attr('data-oe-id', product_id)
|
||||
.data('oe-model', 'product.product').data('oe-id', product_id);
|
||||
}
|
||||
|
||||
$('.oe_website_sale').each(function () {
|
||||
var oe_website_sale = this;
|
||||
|
||||
|
@ -146,9 +154,7 @@ $('.oe_website_sale').each(function () {
|
|||
var $parent = $(this).closest('.js_product');
|
||||
$parent.find(".oe_default_price:first .oe_currency_value").html( price_to_str(+$(this).data('lst_price')) );
|
||||
$parent.find(".oe_price:first .oe_currency_value").html(price_to_str(+$(this).data('price')) );
|
||||
|
||||
var $img = $(this).closest('tr.js_product, .oe_website_sale').find('span[data-oe-model^="product."][data-oe-type="image"] img:first, img.product_detail_img');
|
||||
$img.attr("src", "/website/image/product.product/" + $(this).val() + "/image");
|
||||
update_product_image(this, +$(this).val());
|
||||
});
|
||||
|
||||
$(oe_website_sale).on('change', 'input.js_variant_change, select.js_variant_change, ul[data-attribute_value_ids]', function (ev) {
|
||||
|
@ -184,10 +190,7 @@ $('.oe_website_sale').each(function () {
|
|||
}
|
||||
|
||||
if (product_id) {
|
||||
var $img = $(this).closest('tr.js_product, .oe_website_sale').find('span[data-oe-model^="product."][data-oe-type="image"] img:first, img.product_detail_img');
|
||||
$img.attr("src", "/website/image/product.product/" + product_id + "/image");
|
||||
$img.parent().attr('data-oe-model', 'product.product').attr('data-oe-id', product_id)
|
||||
.data('oe-model', 'product.product').data('oe-id', product_id);
|
||||
update_product_image(this, product_id);
|
||||
}
|
||||
|
||||
$parent.find("input.js_variant_change:radio, select.js_variant_change").each(function () {
|
||||
|
|
Loading…
Reference in New Issue