Skip to content
Snippets Groups Projects
Commit 195c2fc0 authored by Nicolas Martinelli's avatar Nicolas Martinelli Committed by Nicolas Martinelli
Browse files

[FIX] website_sale: performance with carousel

When the carousel is activated, the following will load all variant ids
in the cache (cf. `_in_cache_without`):
```
<t t-set="variant_img" t-value="any(product.mapped('product_variant_ids.image_variant'))"/>
```

When accessing the `image` field at:
```
<div t-if="variant_img" class="..." itemprop="image" t-field="product.product_variant_id.image" t-options="..."/>
```
All variants in cache will have their image resized by the method
`_compute_images` on `product.product`. In case of a product with
hundreds of variants with images, this will take a major amount of time.

If we replace by `product[:1]`, the system uses another cache, and
doesn't fetch the image of all variants.

opw-1844783
parent 074ec1ae
No related branches found
No related tags found
No related merge requests found
......@@ -417,7 +417,7 @@
<div id="o-carousel-product" class="carousel slide" data-ride="carousel" data-interval="0">
<div class="carousel-outer">
<div class="carousel-inner">
<div t-if="variant_img" class="item active" itemprop="image" t-field="product.product_variant_id.image" t-options="{'widget': 'image', 'class': 'product_detail_img js_variant_img', 'alt-field': 'name', 'zoom': 'image', 'unique': product['__last_update'] + (product.product_variant_id['__last_update'] or '')}"/>
<div t-if="variant_img" class="item active" itemprop="image" t-field="product[:1].product_variant_id.image" t-options="{'widget': 'image', 'class': 'product_detail_img js_variant_img', 'alt-field': 'name', 'zoom': 'image', 'unique': product['__last_update'] + (product.product_variant_id['__last_update'] or '')}"/>
<div t-attf-class="item#{'' if variant_img else ' active'}" itemprop="image" t-field="product.image" t-options="{'widget': 'image', 'class': 'product_detail_img', 'alt-field': 'name', 'zoom': 'image', 'unique': product['__last_update']}"/>
<t t-if="len(image_ids)" t-foreach="image_ids" t-as="pimg">
<div class="item" t-field="pimg.image" t-options='{"widget": "image", "class": "product_detail_img", "alt-field": "name", "zoom": "image" }'/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment