Set image field link to product display node not product entity
I have created a View to display products in grid format through adding a Views relationship - product reference. Each product grid contains three fields: content title, product image and product price.
Both content title and product image should link to the actual product display node. Content title is simple. But if link product image field to the content, it's not the node, but product entity which only administrative users are able to see.
To overcome this, I have added a hidden nid field and ordered it before product image field, and rewrite the result of product image field by "output this field as a link" with link path "node/[nid]". This enables the image field to link to the product display node and takes care of URL alias as well.
Is there a better way to do it?
Comments
Make a view of *nodes* with a relationship on *product*
You'll need to make a view of nodes and display the product reference nodes, and create a relationship to the related product. Then you can use the image from the related product.
Note that you need a patch right now though due to changes in Views 3: https://drupal.org/node/1131192
Maybe a stupid question but
Maybe a stupid question but how did you manage to link the content title to the product node and not to the product entity?
Screencast on using a relationship to get to the node
Here's the screencast I just did on using views of product display nodes: http://vimeo.com/22746978
Referenced product relationship
Thanks Randy, the screencast is great. I was also looking at the issue you have submitted: https://drupal.org/node/1131192. The "Add relationship" image contains 3 duplicate "Content: Referenced product". I am using Views (7.x-3.0-beta3), and I have not yet applied your patch. I see the following in my add relationship:
- Content: Referenced product
- Fields: Referenced product
- Fields: Referenced product (delta)
I was able to get it working with "Fields: Referenced product" (not delta), not "Content: Referenced product", as in the screencast 3:34. Shouldn't "referenced product" be a type of field not content (node)?
Second thing is in the screencast 6:08, there is "Link image to", if you selected content, does it link to product display node or product entity? I would like the image link to the node, therefore, I had to use rewrite.
Update to beta3
That patch got committed yesterday and went into beta3, so please update to beta3 or the latest dev.
You can create links of nearly any kind, and you can rewrite, as you say.
I don't get this working
I don't get this working: Link image to product display node. I use the latest dev versions of commerce and views.
I need to link an image to the Product Display node but it's linked to the product type.
Is there any update on this
Is there any update on this issue? Because even using the latest dev version of Commerce and Views, the product image still link to Product Administration Page rather than Product Display page and non-administrator user will see no link on image.
http://www.drupalcommerce.org/node/556
The issue has been answered here
http://www.drupalcommerce.org/node/556