1

Drupal 8, commerce 2: I would like to make a a view of commerce products and show a) the title of the product b) the image of one of the product_variations, e.g. at delta 0. What I have done: * view of products

  • add relationship to product_variations

  • add the variation image field for display

-- this gets me a list of products and images, but it is in essence a list of variations, with the product title repeated over the different images, so

  • I turn on aggregation and

-- I get this error: Table 'mytable.commerce_product_variation__field_variation_image' doesn't exist:

WITHOUT the product_variation image field and aggregation on, I have the correct list of product titles.

This seems like a pretty basic need for a view of products, without we put an image field directly on the product.

One alternative I have explored is to do a rendered entity of the Product and make simplified view modes for the product_variation and product, then set the display mode for the entity in the view, but I will have to customize the field display for every type of product_variation and product I have, and in my one test its still not right, giving me duplicate variation images stacked under the product title, and there is no way to specify "link to content" when using the rendered entity, or do any custom buttons as you might do using fields. I suppose its possible to get this way to work using twig templates, but it seems a lot tougher than if we could have a working aggregation while using a relationship.

1 Answer 1

1

Here's how I did mine :

  • View of products
  • Add relationsip: variation image
  • Add that relation in the fields displayed (You'll now get all the images for the product
  • Add a field Product variation delta
  • Add a filter with the delta which equals to 0 (which will show the image of the first variation).

It's not perfect as if the first variation as no images, it think it won't show up... But it should fits quite some cases.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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