Discussions

Product image on Views link to product admin rather than product display page?

Hi all, currently I'm making a View call new_products to display a list of latest update product. After few attempt, I have create a simple page and block to display Title & Product:Image field.

Now I have 2 problem.

1st, the product image is NOT link to the product display page, but it's link to product admin page although i have set the "LINK IMAGE TO" to "CONTENT".

2nd, 1 product can have multiple image but on this view I only need the first image. But after few hours of searching and trying, I still have no success. Can someone help me where can I limit the result to be 1st image only?

Thank you.

Posted: Jun 7, 2011

Comments

sledan on June 7, 2011

Have same problem. Though it only happens when you are logged in as an administrator. When you are anonymous, the image links back to the front page.

maxchock on June 8, 2011

link back to the front page as the permission denied the access??

Do you have any idea about configuring the views to show 1st image of the product?
SOLVED: By update to latest dev version of Commerce and Views I can control which image to show on the Views.

spamator12 on February 27, 2012

"Do you have any idea about configuring the views to show 1st image of the product?
SOLVED: By update to latest dev version of Commerce and Views I can control which image to show on the Views."

Could you give an example how to do this ?

neardark on June 8, 2011
  1. In your view, make sure you set up a Relationship for your products. In views, under the Relationship heading, choose Add, then select Fields -> Referenced Product. I believe you'll want to check the Require this Relationship* checkbox.
  2. Add a field to your view for Content: Path. Exclude from Display this field and set this field order to be the first field (it is important this field appears before you photo field or you won't be able to use its [path] token (see below).
  3. Edit your photo field. Under Rewrite Results choose Output this field as a link and use the token [path].

*Require this Relationship alone might make this all work without the rest of my instructions but it's late and no time to test this. This all might be related to this issue: https://drupal.org/node/1131192

Brian on January 30, 2012

thanks, this works. But there is a problem with multilingual settings. I use the setting www.example.com/en/... and the link to the products were put out as www.example.com/en//en/...

To avoid this I switched to "Use absolute path" in the settings of the new hidden field (path).

billyverde on March 16, 2012

I'm having the same problem as the original poster, but regarding neardark's solution... in step 1, when editing this View, I do not get an option to choose 'Fields -> Referenced Product' when setting up a relationship. My choices are:

Commerce Line item: Referenced product
Commerce Product: Creator
Commerce Product: Node referencing products from field_product
Commerce Product: Image (field_image:fid)
Content: Referenced product
Content: Image (field_image:fid)
Field: Image (field_image:fid)

Tried all of the above relationships, but in every single case clicking on the image as a non-logged in user takes me to an Access Denied page. I've checked Permissions, and all appplicable View Content/View Product permissions are unrestricted.

Any other clues for this Drupal Commerce newbie?

guaka on May 29, 2012

Now I switched to absolute path and it's slightly working, e.g. links to example.com//node-name.
But it's still broken for nodes with umlauts in the title. :(

And that was for my main products view. The images in taxonomy views are still linking to product admin stuff - and it seems it has the same settings...

EMHmark7 on May 4, 2013

For me, it works, but I needed to Link image to NOTHING, so it allows Rewrite Result to work fine!
Thanks for the hints.

EMHmark7 on May 5, 2013

I found another way that works if we want to take advantage of Search API for indexing anf facets (the checkbox and slider widget blocks).
Here it is:

Clone the Display Products view (I did not try doing something out of Kickstart yet).
In Grid settings, you can put 3 colums.
Show: fields (important)
The field is Content: Rendered Node (you can exclude it from display, but keep it!)

Add a relationship: Indexed Node: product variations
Add a field: (product variations) Commerce Product Image (Image) with delta 0, show as link

et voila! (more exactly et voilà, if your browser displays that letter with accent)

Then you can go in Blocks, put a facet in a region, and configure by adding your page name in 'Only the listed pages'.

Maybe my solution is taking more overhead than needed but it works and takes advantage of Search API that is maybe faster than the Views indexing (I do not know the involved technology well, so just a guess!)

ursula00 on January 21, 2013

Thanks for the explanation but I can't get my image to be linked at all in my view. I have an unformatted list, with a relationship to Content:Product. I have the Referenced Product) Field Image and the path to content placed above the image field and still can't get the image to link. I even applied the category image to the product display and although the image is shown it's not a link, just an image in a div.

What is the actual value that needs to be in the rewrite section is it literally '[path]' ?

Not sure what I'm doing wrong as the image is displayed but I want it so that you can click on the image to take you to the product. The image title works fine but not the image. Any ideas?

crns13@gmail.com caco on October 2, 2014

Thanks very much @neardark. That was exactly what I was looking for.

scott.carlton on September 27, 2011

I have this problem too. Tried the work around but not working. I am on Views 7.x-3.0-rc1 with Commerce 1.0. the the relationship is set to Content: Product Reference with fields set up in the following order.

(Product Reference) Field: Image
Content: Product
(Product Reference) Commerce Product: Price
(Product Reference) Commerce Product: Add to Cart form

any suggestions?

Brian on January 30, 2012

Maybe, in the settings of the commerce image try changing the drop down menu "Link to" to "nothing". It's the one just below "Formatter" and "Appearance".

ahimsauzi on February 25, 2012

I don't think you need the Content: Product field if you added a referenced product relationship. All referenced fields are brought over via the Product Reference prefix (as oppose to content). I am not sure why views shows those fields as available when they actually not...

Also very important when rewriting the image field into a link and adding the [Path] token, make sure to have the "Link image to" Set to "Nothing".

Hope this helps someone...

spamator12 on March 1, 2012

"2nd, 1 product can have multiple image but on this view I only need the first image. But after few hours of searching and trying, I still have no success. Can someone help me where can I limit the result to be 1st image only?"

I have exactly the same problem. I got T-shirt node with few variations black, red, blue I want to display only one - first image. I don't know how to do this... After few hours I gave up...
[views 3.3, commerce 1.2]

EDIT:

Actually I have menage to do it by setting Poduct Reference:delta to 0!

@maxchock thx ! You made my day ! It resolve my multilingual problems :)