0

I'm trying to improve the performance of the craft commerce checkout process.

I have some image thumbnails in the cart. Since I can't cache the cart I want to use eager loading for improving the db queries. But the cart handle is an available tag and I don't have to call a section, so I don't understand how to use eager loading in this case:

Working code:

{% for item in cart.lineItems.all() %}
   {% for asset in item.productThumb.all() %}
     {# blabla #}
   {% endfor %}
{% endfor %}

If I don't have to call: craft.entries.section('xyz') how do I add the with property?

{# this is not working #}
{% for item in cart.lineItems.with(['productThumb']) %}
   <img src="{{ item.productThumb[0].url }}" />
{% endfor %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.