Discussions

Views--Display of Multiattribute Nodes

I can set up a view that shows the various product displays for single attribute displays. When I do the same thing for displays that have multiple attributes, the view shows all of the variations withing each display--not just the display node itself. For example, when I need the view to show T-Shirt-A and T-Shirt B, it shows T-Shirt-A Size S, T-Shirt-A Size M, T-Shirt-A Size L, T-Shirt-B Size S, T-Shirt-B Size M, T-Shirt-B Size L, etc. This is way too repetitive for the user to see four-five variations of each product display--I just need one to show that links to the node and not the product entity.

I hope I'm clear. Once I set up a relationship to Content: Product Reference and add one of the product fields such as (Referenced Product) Commerce Product: Image, the view no longer displays just the product display nodes but repeats all of the variations.

Please advise--this is really complicating completion of a site.

Thanks.

Posted: Jun 27, 2011

Comments

fakingfantastic on June 27, 2011

While I haven't even installed Drupal Commerce yet, I am pretty good with views. It sounds like you need to group on a specific field to keep the sizes from throwing duplicates.

About to install, ill try to report back - in the meantime, let me know if you come up with anything

dkagon on June 27, 2011

I was wondering if you had any luck with this? Anyone else create views that shows only the individual product display nodes and is not repeated for every sku that is in the product reference field of the product display nodes?

fakingfantastic on June 28, 2011

I still haven't done it yet, but as im sitting here - the node references (all the different variations of the product) should have a node reference table like so

PRODUCT | VARIATION
NID:1 | NID: 2
NID:1 | NID: 3
NID:1 | NID: 4

You should be able to group on that Product attribute in the node reference which will only return one unique instance

Let me know if that works

distinctMax on July 13, 2011

Could one of you more experienced Views gurus lead us by the hand?

All my readings over at drupal.org suggest grouping to return a unique node can't be done without custom modules??

indeed when I group by say, title field in my Views formatter, All that happens is all product variations (i.e. those with multiple attributes) are put together in a table/div.

How do you group to return a unique value (i.e. the a single result representing a unique product display)

vbest

Max

jakonore on August 12, 2011

It is a normal behavior for view. As soon as you add a relationship to the referenced products it will display all variations of the product.

If you want a single display you can do as follow:
- Add the Node id of the node which is used as a product display
- Exclude it from the view so it is not shown to end users
- In 'Advanced' > 'Query Settings' click on 'Distinct'

The Distinct setting will make sure you only have one line per node ID so it will get rid off all the product variations.

Hope this will help.

Casper on September 8, 2011

I had the same problem, the solution I came up with was adding an extra product reference field to my product display set to a single value (size small for example) and use this product reference for the relationship.

mplsdan on September 21, 2011

Casper, can you tell me how to do this? I can add an extra product reference field to my product display, but how do I set it to a single value? I've been looking for a solution to this overall display problem all week, and your solution sounds good, I just don't know the finer points of it. Thank you.

Casper on November 30, 2011

To assign the attributes to a product display, you select multiple product entities in the product reference field, autocomplete comma separated or a multiple value select box, with the extra reference field you only select one product (one value) size small for example and you use this reference field as the relationship in your view, this way there are no duplicates.

drupiton on December 28, 2011

one way:
- after you have created your product like a t-shirt with multiple attributes like size, color, style
- make content type product display with referenced product field
- create separate content for each t-shirt like product with variations and reference the similar products from the referenced product field.
- in views you will have to display this as a content of product_display (whatever you have named it) and select the view type as full or teaser depending how you need the attributes to be displayed. Views will not configure and select different fields using this method and configuration would have to be done through the content display settings of full/teaser/user def.
- note: to make sure the multiple attributes is selectable make sure you have configured the settings in product_display content type display settings for the add to cart form.
ps: this method might run into problems while theming, and creating all those nodes might seem a lot of work if the number of products are large. There is bulk product creation module that supposedly fixes this problem but haven't used it yet and cant seem to find other way to display. this might also be possible through the use of aggregation in views advanced column but i cant seem to work that also. using relationships also has been talked about for this situation but cant seem to work it using that also. any other methods ?

2nd way:
- similar to first but if you aren't concerned about showing the different variations of the products then it might suffice. follow the first 3 steps and then in views settings: show commerce product-> of type..
- add the fields to display
- and to eliminate the variations: under filter criteria-> filter by your product_display content type's product reference delta field: ex: if my product reference field is
Label name field widget operations
Product Details field_prod Product reference Select list edit delete
then it would show up as content:Product Details(field_prod:delta) and give the relation as = 1.

drupiton on December 28, 2011

got it working through relationships also:
- after the first 3 steps
- create view of content-> select type.
- i used block view-> grid -> teasers -> with links -> without comments
- change show to fields.
- IMP: to show image fields first create a relationship->views 3rd column. add (content:referenced product) relationship.
- this will create multiple instances of the product variation so take this out add filter: filter by your product_display content type's product reference delta field: ex: if my product reference field is
Label : name : field : widget : operations
Product Details : field_prod : Product reference : Select list : edit delete
then it would show up as content:Product Details(field_prod:delta) and give the relation as = 1.
- this will show only 1 instance of product
- add required fields to display for the product as necessary. to show the multival attributes of the content that was created. chose under fields to display content:product details.. in this the product details is label that i have provided for product reference field in the product content type.

daobydesign on September 10, 2012

The advice in this comment by Drupiton works very well, but I found it a bit confusing. Here are slightly clearer instructions (IMO -- and huge props to Drupiton though.

After creating your view, and noticing that you're getting duplicate products (all variations) in the results it returns, simply add a new filter under FILTER CRITERIA of the type "Content: Product Reference (field_product_reference:delta)".

The filter configuration screen will come up. You should set the Relationship field to your Drupal Commerce product type, and set the Operator setting to "is equal to" and a value of "0". This value may need to be different under different product/views configurations. Generally it will be "0" (ie. the first product of the variations), but if this doesn't work for you, simply add the same field above, "Content: Product Reference (field_product_reference:delta)", as a visible field under the Fields section and check out what the common delta # is for the items you wish to display.

Thanks again to Drupiton for the original answer to this.