The cart of Craft Commerce can't really be cached so I try to increase performance by loading product images in the cart via eager-loading.
All tutorials tell me to use the .with(['variantThumb'])
. But .with
can only be used on the craft.entries().section
and not on simple loops, I don't understand how to do this.
The stuff in the cart is available via the cart
handle:
{% for item in cart.lineItems %}
{% set cartThumb = item.purchasable.variantThumb.one() %}
{{ macro.checkoutThumb(cartThumb) }}
{% endfor %}
I don't understand how to use eager-loading in this case.