4

I am trying to list other products in the same category using the Views module when browsing a product.

For example, I am browsing drinks/drupal-commerce-wake-you; I want to list all other products in the "drinks" category, to build similar, or related products.

How can I achieve this?

  • 1
    Step by step tutorial to list related products with views and entity reference can be found here : drupal.org/node/1465920 – AjitS Mar 12 '13 at 6:03
7

Try this

  1. Create view (block)
  2. Add fields (title, a small image, date, whatever you like). Or teasers, what works as well.
  3. “Arguments” is from now on called “Contextual filters”, so go there.
  4. Add the filters: “Content: Has taxonomy term ID (with depth)” and “Content: Has taxonomy term ID depth modifier”
  5. Configuration on this filter: → When the filter value is NOT in the URL: → Provide default value → Type: Taxonomy Term ID from URL → under that, check the box “Load default filter from node page, that’s good for related taxonomy blocks.” → now check the boxes of the taxonomies you want involved here
  6. Now you need to add the second filter in order to exclude the current node from the list. Click [+] button of the contextual filters section.
  7. Select Content: Nid
  8. Set the ‘when argument is not present’ to ‘Provide default argument’
  9. Set the ‘Default argument type’ to ‘Content ID from URL’
  10. Go to “MORE” , and check the “Exclude” box.
  11. Move the filter “Content: Nid” to the top position.
  12. Add a block to your view and embed the block on your node pages
  13. Save your view
| improve this answer | |
  • This was great I just modified it slightly to include some relationships with specific vocabularies since if you don't set that you pretty much get all products in the system if you have multiple vocabularies associated to nodes :/ – shaneonabike Jan 25 '15 at 21:20
  • This used to work for me. Now, however, although I can create a view that displays other products in the same category when I provide the NID and TID in the View preview, nothing displays on the product page when I add the block to the page. I guess I'm doing something wrong but I can't figure out what that might be. – millionleaves Jan 27 at 23:41
0

Another easy solution is creating a taxonomy of categories or whatever variation types you want to filter; add the taxonomy to your product fields.
Create a view adding the Has Taxonomy Term, selecting the taxonomy you added.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.