Use "Content" or "Commerce Product" in Views?
I am trying to make a View showing a few text fields + a product image with an image style (200x200px). The View is set to display a specified number of items.
Now, I first tried setting up a View showing 'Content' of type 'Product display'. But when trying to add fields to display in this View, I can't seem to target the fields I have set up in "manage fields" in "products types".
I then proceeded to create a View showing 'Commerce Product' of type 'Product'. This worked great. Could now target all fields I fill out when adding a product. By setting the filter 'field_product:delta', I could even make sure that a product with varitions just show up once in the View - and not once for every variation.
Everything great - except this act as an administrator view only. When clicking on images I am not taken to the product display but to the backend product page. Further, I can't even see the View when not logged in.
Is this because I actually have to make a product display completely duplicating every field entered when adding the actual product? Please tell me no.
If the answer is yes, as I fear, is there a workaround to make usable Views out of the fields in 'products' and avoid using 'product displays'?
Drupal Commerce seems great in many respects, but this duplication of 'product'/'product display' completely undermines it, in my opinion. It adds tons of work and makes everything complex, confusing and illogical.
I hope a version 1.1 will include a solution.
Comments
A view of nodes has to have a
A view of nodes has to have a *relationship* on the product reference field for you to access those fields.
A view of products may work for you, but sometimes is wrong if you don't want the users who will use it to have access to products, which are normally an administrative concept.
Got it, and it works. Thanks
Got it, and it works. Thanks a lot!
Or so I thought. Fields in
Or so I thought. Fields in the View still link to admin pages, so relationships don't seem to work either.
I simply can't get my head around it. How do I create different Views of my products?
Correction. I can't get my
Correction. I can't get my head around how I create different Views of my Product Displays.
If you're trying to get the
If you're trying to get the image to link to the Product display you could try the following:
Note: This may only work if you have pretty permalinks enabled. I'm not sure.
Explanation of what's going on here (for those interested and/or new to Views):
In the last step here we use the token "[path]" to make the image link to the path of the product display. If you scroll down a bit from where we entered "[path]" you'll see a "Replacement patterns" section which will probably have a few different options. These options are the other fields you have in the view. Thus, we added the "Content: Path" field and now we can use it as a token here. We exclude it from display because we don't want to see it in the View output. Notice that for a field to be a token it has to come before the field you want to use it in. For example, if you rearranged the fields in this view so that the image field came before the path field, you wouldn't be able to use the "[path]" token when rewriting the image link. That's why we move the path field to be the first field. Hopefully this is helpful to someone. Let me know if any of this is inaccurate.
Cheers
Appreciate it, sounds like it
Appreciate it, sounds like it could work. But the relative complexity of achieving something that should be quite simple baffles me. Say you've got a front page with links to a few articles and some basic info. As a little teaser you also want a block with a view of, say, 8 of your products sorted after some criteria or another. Just the image and the name of the product. When the user clicks on it, he should of course be taken to that product's display.
This is standard fare on most ecommerce sites and should/could be super simple to set up. Maybe I am misunderstanding something, but I have just installed Ubercart to see if the approach here is more intuitive. Will post my findings here later.
Problems in Views RC3 with Relationships
Everybody here should know that in Views 7.x-3.0-rc3 (and thus Commerce 1.1), there has been a security crackdown on relationships, and by default a view of nodes with a relationship to products won't work for users who do not have privileges to access the products. See the [issue](http://drupal.org/node/1276450) for more details. There is a workaround (disable query rewriting) explained [here](http://drupal.org/node/1276900#comment-4980066).