Score:0

Split a hierarchal taxonomy into multiple facet filters

cn flag

I'm currently working with an E-Commerce site in Drupal 8 that contains multiple products and multiple specifications set up in a hierarchical taxonomy term called Specifications like this example:

  • Color
    • Black
    • Blue
    • Silver
    • Copper
    • Navy
  • Material
    • Plastic
    • Aluminum
    • Steel

There are many more in practice for this platform, and the product content type contains a taxonomy term repeater field for multiple child level specifications.

For example a product might be colored Silver and have Aluminum material.

This site is utilizing Search API using Apache Solr configured and currently running with indexed data for this field, and with hierarchal indexing enabled for the product's specification field. There's also currently a single facet filter for the Specifications field as well.

The requirement for this project however is that each top level parent taxonomy term is its own facet filter separated such that renders and acts as its own filter block, instead of the default single block that renders all parent and child taxonomy terms under Specifications.

Any suggestions for implementing this?

Jacob avatar
cn flag
Note: Not sure if this is an entire solution but for those looking to do the same, conclusion I came to was to duplicate an existing widget, say checkboxes, then use jQUery to clone the facet blocks with the number of parent terms and only include those child terms per cloned parent facet block and adjust the block title with it based on the parent term link text. Make sure your context is now the cloned facet blocks passed from attached behavior parameters, and adjust any other context references as necessary. If you want to resolve any `this` references w/o es6, either bind or use for loops.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.