- π©πͺGermany Anybody Porta Westfalica
@Maintainers: Do you also agree with #14? Then we could proceed here for 3.0.x!
Another alternative would be to have all fields as pseudo-fields on the product variation, if the option is selected. That would be even more flexible and would put these even at the display configuration level for all display modes!
I think one of both ways should be chosen!
- π¬π§United Kingdom newaytech
For anyone else landing here - I worked around this by:
- disabling the tick box to inject the variants
- For the default product view - tick layout options > Use Layout Builder
- Within layout builder - then add "Variations" field - using "Add to cart form" formatter
- Within layout builder - then add "Default variation" field - using Rendered entity formatter and bespoke View mode if needed
- π©πͺGermany Anybody Porta Westfalica
Thanks @newaytech - that shows there's still demand for this. I'd love to get some maintainer feedback i #14 to proceed here.
- πΊπΈUnited States loze Los Angeles
For the record I would love to see this too.
- πΊπΈUnited States chrisolof
I found that what's outlined in comment 11 works to achieve something similar to what I think the OP was trying to do. In my case I needed to render the product full/default view with most product variation fields showing, and in product lists I needed a "teaser" type of output where only some fields were shown, sometimes with different output settings.
To achieve this I:
1. Set up same-named "Teaser" view modes (
/admin/structure/display-modes/view
) for both the Product and Product variation (enabled for the sub-types that needed it).
2. Configured the display settings for each, reducing and changing how certain fields were rendered in the teaser view modes via each Product/Product variation field's display settings.
3. Created bothcommerce-product.html.twig
andcommerce-product--teaser.html.twig
template files with statements like{{- product.variation_field_foo -}}
and{{- product.variation_field_bar -}}
to render the fields where needed. It sounds like layout builder could be employed here as an alternative to this template-based approach (see #2716417-22: Allow rendering of variation fields on the product entity. β ).
4. Selected the "Teaser" view mode for products in views-driven product lists.Seems to work great.
I agree with comment 14 that it would certainly be nice if we did not have to rely on this same-name magic and could instead select the desired product variation view mode from the product view mode's display settings (defaulting to current behavior).