In my type of product variation, I have 4 different display :

  • Default
  • Panier (Cart)
  • Teaser
  • Teaser relation

enter image description here

I have created a template for product type and want to display the "Photo" field of the "Teaser" display of the product variation type.

Here is what I put in my template:

{{ product.variation_field_produit_image }}

The problem is that it displays the "Photo" field of the "Default" display.

How to get the "Photo" field of the "Teaser" display?

  • It should be taking the one from the matching view mode, "teaser" in your case. Can you check whether you're running latest Commerce (2.9)? – Bojan Zivanovic Oct 10 '18 at 16:15

You can create another template for that specific view mode.

The naming of that template should be commerce-product-variation--product-type--view-mode.html.twig.

So you can create a template called commerce-product-variation--PRODUCTTYPE--teaser.html.twig, and then print the image field from there.

  • Thank you, but that's not my question. I already have this file. I want to display a precise display mode of the type of variation – 553aa08930 Oct 11 '18 at 0:49

Try the bamboo twig module with

{{ bamboo_render_image_style('public://antistatique.jpg', 'thumbnail') }}


{{ bamboo_render_entity('node', 2, 'teaser') }}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.