Closed (fixed)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Views integration
Priority:
Normal
Category:
Task
Issue tags:
Reporter:
Created:
28 Mar 2011 at 16:46 UTC
Updated:
1 Oct 2018 at 02:13 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
latulipeblanche commentedStephanie,
Did you trouve a solution for this issue ?
I tried to get a view with the color variations of my colors and, like you, I didn't get the images linked to the product display of the product with that specific color.
Here is the item I put on drupalcommerce.org: http://www.drupalcommerce.org/node/466 .
Comment #2
rszrama commentedAhh, hmm, missed this issue somehow. Product line items have a "display path" field on them used to link to the product display from which the product was added to the cart. The field should contain a path to the appropriate page, so if you include it in the View (but don't display it) you can add a link to the product title using that field's Token in the View. Not sure if that makes sense, but if an example helps, check out the default cart block View.
Comment #3
latulipeblanche commentedRyan, I tried to get the view working but the "relationship" needed wasn't in the list, so I need to find out how to do it.
But I was wondering if you could help me with this, what is maybe a better way to get this done.
With the module "commerce_cart_options" I changed the dropDown-list in radio buttons. Next I put a image, representing the color to replace the radio-button. But this is don fixed.
What I need to finish the whole thing is how to get the link to be dynamicaly instead of fixed, relative to the url. The url looks like this : ~/content/tshirt . Do I need a Query in MySql or ...
Tnx a lot for your help (and for Commerce :) )
I feel that it I'm close to the end(I'm looking for this for some weeks now :( ) .Comment #4
latulipeblanche commentedI don't get it work.
Not the view-way, not the module-way.
When I try to make a View, I don't get the "display-path" working with the "color-image".
When creating a view I made a view with fields :
Commerce Product: Product ID (Product ID)
Product: Type product (Type product)
Product: Image color
In no way I get the relationship "display-path".
I tried other views based on taxonomy-terms, commerce-line-item, commerce-product.
All this , just to replace the dropdown menu by representing images :( . Wish I was a better developer ...
Comment #5
bojanz commentedThe "display path" is a field available when the base table is Commerce Line Item.
If you want to relate products to nodes referencing them, you need an inverse relationship, which as you've noticed is missing.
Here's a patch that implements it, and a screenshot.
I've made it exclude the relationship from line items to products because it doesn't seem useful, but that can easily be changed.
Comment #6
rfayWow, fantastic. Note that this may produce duplicate rows if there is more than one node presenting a product.
Comment #7
bojanz commentedYup. And actually the join is currently wrong (it's joining products and nodes on nid = product_id), so standby for another patch...
Comment #8
bojanz commentedHere's a working patch. The previous one was missing a chunk.
Comment #9
latulipeblanche commented@bojanz
I missed the IRC-message.
I was able to make a view showing the color-images. There is still one problem, that is that the image is linking to the admin-page. When I try to rewrite the results, I cannot chose "replacement patterns".
Token is installed ??
Comment #10
bojanz commented@latulipeblanche
Works for me. Note that only the views fields that come BEFORE the field you're rewriting have their tokens shown in "Replacement patterns".
So add a hidden nid field before the image, and use it happily.
The patch seems to be working okay, so I've also created a branch for it in my sandbox:
http://drupalcode.org/sandbox/bojanz/1097750.git/commitdiff/21c8b14547b5...
Comment #11
liupascal commentedWould it be possible to make the link redirect to the product display with the right product's attributes selected ? Because if I added a Blue shirt rather than a Red and that the blue is the first product reference, then i'll end up redirected to the blue shirt which can be confusing. Might be related to #1082596: Implement unique URLs for particular products on product displays somehow ?
Comment #12
rszrama commentedPatch appears to work just fine for me. : )
@liupascal - yeah, that would require functionality on product display nodes that just isn't there. We'll have to wait on a patch to the issue you linked before that could be considered.
Comment #13
khiminrm commentedSubscribe
Comment #15
summit commentedHi, Is this patch committed please?
greetings, Martijn
Comment #16
rszrama commentedYep, it was committed last June.
Comment #17
FriedJam commentedIgnore me - issue resolved!
Comment #18
rszrama commentedGlad to hear it.
Comment #19
ontwerphuis commentedHi Thanks this is exactly what i need to do.
@ bojanz how do I implement your patch? Sorry i'm still relatively new to drupal.
Thanks in advance
Comment #20
ontwerphuis commentedI'm running OS and using Terminal to install the patch but get the below error
$ patch < 1108180-inverse-relationship_0.patch
patching file commerce_product_reference.module
Hunk #1 FAILED at 592.
Hunk #2 succeeded at 829 (offset 202 lines).
1 out of 2 hunks FAILED -- saving rejects to file commerce_product_reference.module.rej
Any idea how to sort this?
Comment #21
rszrama commentedYou can just update to 7.x-1.x-dev and run update.php.
Comment #22
Anonymous (not verified) commented[solved]
"Link to Product Display node from view of Products, not product admin"
I've just spent the last 2 days trying to solve this problem and running into terrible advice everywhere.
goal: click on image [as displayed in a block or page] from a view and go to the PRODUCT NODE page NOT the PRODUCT ADMIN PAGE!!!!
Through near-endless trial and error I FINALLY got this seemingly easy problem solved! I felt I should share the solution considering the pain it caused me. I hope it can help someone out there.
note: I was using Drupal 7.18, commerce kick starter 1.x. + I was trying to set up a jCarousel horizontal slider.
1. Create your view in the standard way: view of content type "product display".
2. In your new View config page: Establish a relationship with "Content: Referenced Product" * if you don't have this done, you'll have to google "how to add a product reference field to a product display NODE."
3. Once the relationship has been added, add FIELDS "Content: Path" and the (Image field you want to display) I used the 'Commerce: Product Image' field. Make sure the image field is ordered 2nd - after the "Content: Path" field. (apparently this is important or the token can't be used..)
4. CRITICAL!!!! click the "Content: path" field and thus open the "Configure field: Content: Path" configuration screen. In this screen -> click: exclude from display and click: "Rewrite Results".
Then click box (enable): "Use absolute link (begins with "http://")"
and APPLY
5. enter the configuration screen for your image field.
6. make sure the relationship drop-down menu has the relationship from step 2 selected.
7. Make sure the "Link image to" drop down menu is listed as "nothing"!!!!
8. Click "Rewrite Results"
9. Click: "Output this field as a link"
10. In the "Link Path" box put this: "[path]" (of course without the: " )
11. APPLY
12. SAVE VIEW
13. Reload in your browser and now your image should link to product display node and not the annoying product admin page.
I hope that helps.. I didn't get a full solution anywhere on any forum... so I hope this can help someone.
Peace.
p.s. sorry if my instructions are somewhat poorly written & organized, I'm in a hurry.
Good luck, get money!!
- Edacafa
Comment #23
rszrama commentedYep, this is good. Another option is to use a view mode of the node type to render the desired injected product fields, including the product image, because a product image field when rendered into a node display will use the node's path for the "link to content" option as opposed to the product path.
Comment #24
yeiyei commentedHi over there! Subscribing for this issue.
THANK YOU EDACAFA!!, save me a few more days of stuffing around views.
At this moment I´m using Drupal Commerce to develop a chilean marketplace for handracrafts (ikuna.cl). We are almost there, integrating chilean payment methods to drupal commerce. I`ve been trying to solve links from "product views" to "product display nodes" for 2 days, searching the "sort by product price (exposed)" in "Product Display View". The solution proposed by EDACAFA works also for sorting/filternig "Product Display Views" using "Products Fields". When the relationship is created the "Product Fields" appear as a possible selection in sort/filter config inside views.
MAIN ISSUE: "It isimposibleto use product fields, such as price, to sort/filter a product display view".Default Views:
Solution:
Problem:
Comment #25
agileox commented@EDACAFA Excellent Post! #22 ++++
Comment #26
Zac_JH commentedHi
Is it possible to make this inverse relationship available to rules? I would like to force solr to re-index the related product displays when a product goes in or out of stock. I already have a rule that deals with the stock change making a product active or not and it would be great to a rules loop on the action list and force an index of the related product displays.
Comment #27
muschpusch commented@rszrama: #23 actually works in kickstart but not in "plain" drupal commerce. I added the rendered node as "field" like in kickstart. Any idea what i could do wrong?
Comment #28
gianfrasoft commented@FriedJam, how did you solve your problem? I have the same issue!
Comment #29
bmodesign commentedI needed to pull the product display link in as a regular field attached to my product, so I leveraged rules.
I'm sure there is a better way to tweak this, but here's how I made it into a field, because we love fields...
*my products have one display and are only listed on one display per product, so I'm not sure if multiple displays/products will wreck this*
I then have to go in and re-save my products. I'm sure there's a bulk way to do this, but for my shop it took 5min. (not just re-saving the product display, but the actual products referenced too.)
I now have a field attached to my product, that links to my product-display that I can pull up as a linked field wherever I need it.
Here is my rule export.
Hope this helps someone.
Comment #30
VanD commentedI get this error
I tried to recreate the rule myself and I don't have that selector "commerce-product:field-product-node:0:url" or anything close to that.
Comment #31
victor.bexelius commentedHello,
been some frustrated days trying to sort this out with rules and views settings mentioned above. I did not manage to solve the issue with the information provided above - so I ended up with custom template coding. It may not be the best solution, but it gets the job done and Im happy with it.
1. I've created the view for the related products block. In here I am setting the relations and filters as mentioned above. If you are lazy or just had enough googling this issues let me point out the most important keys:
1.1 Advanced settings in view:
Contextual filters: Nid -> provide default value -> Content ID from URL
Relationships: Content: Related products -> Require this relationship
1.2 Fields added to view:
(Products referenced) Commerce Product: SKU <--- this one is the key to make all this work.
+ any other fields you require
1.3 My view export (for your convenience)
2. I've created my own TPL file for the block containing my related products.
Example name of tpl file: views-view--related-products--block.tpl.php
The code for looping out related products in this TPL
Hope this helps anyone out there!
Off topic / Personal tips:
By the way - if you are trying to add items to cart from this related block AND using AJAX for this related block view: You will get an AJAX JSON response instead of the product being added to the cart. I have not resolved this issue yet - but the issue lies within the form action of the add to cart button -> as it gets fubared by the containing form that capsules the whole block to enable the AJAX-view -> thus changing form action of the add to cart button to /view/ajax and fubares the page out.
Update: http://xandeadx.ru/blog/drupal/645 post fix for this issue - but I have not had any luck with it.
Best regards //
Victor
Comment #32
pun_pun commentededacafa, thank you for your solution #22! You saved my nervous system. :)
Comment #33
tomfilepp commentedAll of these solutions are great but, why not just implement this as a default behavior? Why would you want it to default to the admin url at all? Seems like this is overcomplicating a simple thing.
Comment #34
Road Kill commentedThe solution 22 works but only if you have a single product but if you are using product variations then you are out of luck.
If I understand this correctly the patch in 8 has been committed but I cannot find a back reference or reverse reference option in the latest dev. I hope a solution will become available in a future release as this limits builds to content type displays through the view.
Possibly providing a product carousel for product variations on the field would be one solution for variations.
Comment #35
xstanley commentedI was facing this problem also in the latest Kickstart 2 version, so after hours of investigating I was able to prepare these detailed steps how to solve it:
Source: Me and https://drupalcommerce.org/discussions/556/product-image-views-link-prod...
Comment #36
tuccio commentedNot sure if I am missing the obvious, but I am trying to create a simple Commerce Product view and want to add a link to the node(s) referencing each product, but cannot find any inverse relationship to the node referencing the product. It should be available by now, correct?
Comment #37
loparr commented@tuccio
You would want to add another relationship that is made available by adding Products referenced by commerce_product.
Next add: Node referencing products from field_YOURFIELD. This way you can get data form the referencing node.
Comment #38
loparr commentedAnybody solved the issue with duplicates in cart if multiple product displays are referring to one product?
EDIT: after looking to the db, it looks like it is not possible.
Comment #39
webdevdoc commentedOk, Maybe I am missing something so my question is really simple.
How would I make a view to show products on the frontend to anonymous users. This view will include a list of product fields to include a product title and an image. Upon clicking on a product title or clicking on the product image the anonymous user will be taken to the product detail page where they can see all the other fields in the product including the price and an add to cart link.
DOH! - So I am the type to just jump right into things, I started working with products but did not realize that you need to create a new content type for products as a node and then add a product reference field to link the front end node up with the back end product. Quite unusual and was really frustrated trying to figure this out initially and then was like, WTF? why was it created this way, THEN after working with it and thinking about it, I realized that it opened up a world of possibilities, i.e., linking products sold at multiple physical locations (nodes) with 1 product in the back end. I am continuing to explore. Interesting configuration.