Videos

Using Views with Products in Drupal Commerce

Date Published: 
04/22/2011
Duration: 
07:33

In Drupal Commerce, the "product" and "product display node" are different things. So to use views of nodes, we have to use a relationship, which is new to some. This screencast shows how to use a Views Relationship to let a view of nodes access information that's on the product.

Views is up to the task of creating a view of product display nodes and getting their information into the view. First, you'll want to create a view of product display nodes, next you'll want to create a relationship (under advanced) to link the product variations to the product display nodes. Finally, save, and there you have it!

Comments

alexanansi on December 15, 2012

Hi, I had the same problem and found the documentation not very clear. I got it to work by filtering on Content: Product variations (field_product:delta) = 0. This delta field seems to be a unique ID for each variation, so you just need the first item from the list of variations and that has an ID of 0.

matsjacobsson on December 8, 2012

Hi,

I'm doing exactly this but the view does not show for anonymous users.

Do I have to tick the "View any product of any type" permission for anonymous to get this to work? I though that was bad for security..

Cheers Mats

jenifer on March 4, 2013

This is driving me really insane... I just can't fathom out how to do this :-(

All I can manage to achieve is to get the images linking through to the admin pages. Is there a tutorial that demonstrates how to do this? Has anyone worked it out?

I've entered my products in the store as well as created new products (via content type > product).

I've been struggling about a week now trying to work out how to create a view of just the images that links through to more details about the product.

Please post and share how to achieve.

jenifer on March 4, 2013

I'm assuming I did this bit right:

-------- Store -----------

Created 4 products
http://example.com/admin/commerce/products/add/product

Procuct SKU:
Title:
Description:
Image:
Price:

-------- Content type -----------

Create content > Product
http://example.com/admin/structure/types/add

Manage fields:
http://example.com/admin/structure/types/manage/product/fields

Add:
Label: Product reference
Machine name: field_product
Field type: Product reference
Widget: Autocomplete text field

Product types that can be referenced: Product
Product reference field settings: Unlimited

Label: Tags
Machine name: field_tags
Field type: Term reference
Widget: Autocomplete term widget (tagging)

-------- Content -----------

Created 4 content products using create > content > product
http://www.example.com/node/add

Title:
Product reference: (autocomplete to select)
Tags: (autocomplete to select)

-------- View display -----------

What I now can't work out is how to create a view:

IMAGE1 IMAGE2 IMAGE3 IMAGE4

IMAGE5 IMAGE6 IMAGE7 IMAGE8

Each to link to their full content page
http://www.example.com/content/greetings-card

All I seem to be doing is going round in a circle and ending up with the image linking to
http://www.example.com/admin/commerce/products/3

-------- View settings -----------

Format: Grid

Fields: (Product) Field Image
Relationship: Product
Link image to content

Content title

(Product) Commerce Product: Price
Relationship: Product
Formatter: Formatted amount

Relationship: Content: Referenced product
(Product) Field: Image:fid (Relationship: Product)