2

I'm not sure how much sense this makes as I've confused myself so much trying to do this.

I'm using Drupal 7.28 and the Drupal Commerce 7.x-1.9.

Basically the image and the description fields are both on the Product Type not the content type as each product has its own description and image.

In my view I now need to add the image field, but I can't add it, which I believe is because the field isn't in the content type.

When I add the 'Content: Referenced Products' relationship to the view, I am then able to add the image field to my view.

However when I then select to link this image field to the original content, the field links to the admin page where I edit the product - not the content type node that is displaying the product.

Also, after adding the image field, the view lists the image for every single product variation whereas I just need one image that links to the node.

2

This drives me nuts in Drupal Commerce. Now that you have the relationship, add a field to your view Content:Path using the relationship and tick boxes for Exclude from display then go to Rewrite results and tick the box next to Use absolute link (begins with "http://"). Move this field so that it appears above your image field. Then, in your image field, Link image to [Nothing] and under Rewrite results tick Output this field as a link and under Link path enter the token for your path.

Good luck.

  • 1
    Unfortunately, that's just the way the image field works. Your solution is perfect. We also have to work around this on product displays where we can tell if a product image field is being rendered in the context of a node and edit the link path to the node's URL, but when you make the join yourself via Views and render it directly, we have no such context or alteration point to do the same. – Ryan Szrama May 22 '14 at 18:21
  • 1
    Thanks for the comment Ryan, it's good to have a solution validated from the creator of Drupal Commerce! I use this solution all over my Commerce sites in order to get images linked to Product Displays in the cart, cart confirmation popup, and elsewhere. – Link Swanson May 22 '14 at 18:32
  • Thank you very very much this is exactly what I was looking for, glad someone did understand what I meant, thank you. The only problem I face now, is that my view displays the image for every single product under store> products, I just need it to show one of each product. So for example where my view shows the round table, the square table and the rectangle table, I just need it to show one, so the user clicks on that one and then they are taken to the product display where they can use the drop down menu to select the type of table. Are you able to help with this? Thank you v much. – Carl Bowles May 23 '14 at 8:22
  • Basically, at the moment the view is showing every product, I just need it to show one image from each node if you under stand what I mean? – Carl Bowles May 23 '14 at 12:23
  • Yes, I think you need to adjust the Multiple field settings for your field to use the following settings: "Display 1 values starting from 0". Does that help? – Link Swanson May 23 '14 at 14:35

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.