In D10 Product Attributes render without classes / field names

Created on 6 December 2024, 16 days ago

Since upgrading to Drupal 10, I have an issue with displaying product attributes.

I have a site built in drupal 9, commerce 8.2.38, which uses a range of product attributes, here they display fine. I cloned the site, upgraded clone to D10.2, with commerce 8.2.40, then made another clone to D10.3 with commerce 3.0.0-beta1.

Both the 10.2 and the 10.3 strip all field names and classes from the attributes.

In Drupal 9, when rendering these attributes on the product page (in commerce-product.html.twig) using {{ product.field_attribute_x }}, the output is like this:

<div>
      <div class="field field--name-field_attribute_x field--type-entity-reference field--label-hidden field__items">
              <div class="field__item"><div>
            <div class="field field--name-field-attribute-x-image field--type-image field--label-hidden field__item">  <img src="/sites/default/files/styles/product_attribute_image_square/xxx" width="200" height="200" alt="xxx" loading="lazy" typeof="foaf:Image" class="img-fluid">
</div>
      
            <div class="field field--name-field-display-name field--type-string field--label-hidden field__item">xxx</div>
      </div>
</div>

But with unchanged twigs, in Drupal 10 (10.2 and 10.3 both, commerce 8.2.40 and 3.0.0 both), the attribute renders like this:

<div>
      <div>
              <div><div>
            <div>  <img src="/sites/default/files/styles/product_attribute_image_square/xxx" width="200" height="200" alt="xxx" loading="lazy">
</div>
            <div>xxx (is the display name)</div>
      </div>
</div>
              <div>
  </div>

So lots of divs without any classes, field names, etc. As a result all styling and layout from CSS which uses the field names etc, is absent

Is this a new way of rendering in D10? And/or does Commerce product attributes need updating?

Any help / tips greatly appreciated!

🐛 Bug report
Status

Active

Version

3.0

Component

Product

Created by

🇬🇧United Kingdom xax London, UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024