Taxonomy Terms Not Displaying Products

Created on 25 July 2018, almost 6 years ago
Updated 9 September 2023, 10 months ago

I have added product categories vocabulary to my default product type. Added few products through that default product type and selected relevant terms for each product I added.

When I am going to term page it is not displaying the products associated with that term.

πŸ’¬ Support request
Status

Fixed

Version

2.8

Component

Product

Created by

πŸ‡΅πŸ‡°Pakistan fahadurrehman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States rex.barkdoll

    Since this still hasn't been solved in Views/Core, I wanted to add that I was also able to solve this using the TVI module.

    The only problem I can see is that you hit a wall if you want to have Taxonomies that span across nodes and products. You can't do both, so, in my limited understanding, you'll have to create a different Vocabulary for each side, even if that means you have duplicate terms in separate vocabularies. If someone knows better, please show me a way to show both nodes and products on a tag page.

    I appreciated @chike's instructions, but they're a bit minimalist, so here's a more expanded version:

    1. Install the https://www.drupal.org/project/tvi β†’ module and enable it.
    2. Create a new view, you might name it something like "Products per Taxonomy Term"
      • Setup the view however you want show each product in a display mode or with fields - however you want it to display, set it up.
      • Add a no results behavior message that says: "this term doesn't have any products associated with it."
      • Under Advanced > Contextual Filters, add a filter for your Taxonomy Vocabulary (authors, tags, whatever) and when it's not available, set it to Display the contents of No results Found, or hide view.
      • Set the view pagination if needed.
    3. Save the view
    4. Now go to Structure > Taxonomies. Click the dropdown beside your vocabulary and click Edit Vocabulary.
    5. You'll notice a new section on this page called Taxonomy Views Integrator Settings
      • Check the Enable taxonomy views integrator to override presentation. checkbox
      • Find your view in the first dropdown and select it
      • Select the view you want from the second dropdown
      • Optionally check the two checkboxes about children and arguments if they make sense to you.
      • Save the Vocabulary
    6. Now go check out a vocabulary term page and your products should appear. They should show up based on your settings in the view we created.

    Bonus Points:

    1. I wanted to setup a view that showed all the taxonomy terms in my vocabulary. Over the years, our vocabulary (Authors) list has grown, but not every term is still associated with an active product, so I wanted to create a view that shows taxonomy terms with at least one product associated with them.
    2. Create the view, set it to show your Vocabulary, in my case it's Authors.
    3. Get it setup and displaying how you want. (format, fields, filters, Block/page settings, header, footer, no results behavior, and pager.
    4. Advanced > Add a relationship to the product field that contains your vocabulary (in my case: field_authors), check the box to require this relationship
    5. Advanced > Turn on Aggregation and enable the Distinct option in Query Settings
    6. Add an additional filter: Product: Has taxonomy term. Choose your vocabulary and set the Operator to Is Not Empty (NOT NULL)
    7. Hit the apply button.
    8. Your new view should now only show terms that have at least 1 product associated with them.
  • πŸ‡ΊπŸ‡ΈUnited States hockey2112

    @rex.barkdoll, I have several vocabularies that the products are tagged in (category, size, color, etc). Do I need to create a view display for each and every one of my vocabularies? Or is there a way to create a single general view that can function for all product taxonomies using TVI?

  • πŸ‡ΏπŸ‡¦South Africa niki v

    This can also be done with views without the use of any additional modules and is necessary if the number of categories makes facet searching unworkable.

    Create a new taxonomy view, selecting the product taxonomies you want to use
    Select a format that shows fields
    Format should be a page with pagers or whatever else you require

    Edit the view:
    Change the path to /taxonomy/term/%taxonomy_term
    Relationships: relevant product taxonomies (required)
    Add any fields that you wish to show: title, image, etc
    Contextual filters: "Taxonomy Term: term ID"
    Leave the filters provided
    Add any type of sorting that is relevant to you

    Navigating to these taxonomy pages will show your product fields in the same way that the default node view does, but the taxonomy page title will not show. To add a page title, you need to create a new view, which should be a block.

    Do not create a block on the page view you just created, or a custom block, it should be a new view block:

    Show: Taxonomy terms of your relevant product taxonomy, in a format that shows fields with a block display.
    Do not use a pager, show 1 item
    Continue & Edit
    Add the field "Taxonomy term: Name" and in the style settings, select "Customize field HTML" and select HTML element H1
    Add a contextual filter "Taxonomy Term: Term ID"

    Edit the Taxonomy Term view that you created first
    Click on the "add" button in the Header section
    Select "Global: View area"
    Find the new view you created and select the block display
    Check the "Inherit contextual filters" checkbox

    Creating a catalogue page that shows taxonomy terms will require creating a glossary view, there's a tutorial here https://getlevelten.com/blog/kristin-brinner/drupal-tutorial-use-views-c...

Production build 0.69.0 2024