logo

Display Fields Value in Drupal commerce product template in Drupal 8

22
September

Display Fields Value in Drupal commerce product template in Drupal 8
By: Anonymous | Published On: Wed, 09/22/2021 - 19:45

How can display fields value in product template of Drupal commerce in Drupal 8

First have to create template with name "commerce-product.html.twig"

Some examles of fields value which can be use in template to display output

Display user name of product author

{{ product_entity.getOwner.getUsername }}

Display user id of product author

{{ product_entity.getOwnerId }}

Display Product title

{{ product.title }}

Display product image

{{ product.field_image }}

If you want to display all the data excluding some fields then you ca use following format

{{ product|without('variation_attributes', 'field_image','field_images', 'field_reviews', 'field_related_products', 'field_sale','body','field_max_price','field_min_price') }}

Display product body content

{{ product.body }}

Need Help ?