Smart Search has a rather good taxonomy that allows to add a lot of additional filters for the search. However there are 2 flaws:
- Nested taxonomies (like categories) are squashed into a flat list and
- The state of a taxonomy is not updated in the search result.
This PR tries to fix both these flaws.
How does it work?
For legacy finder plugins, everything stays as it was, so we should be pretty much backwards compatible here. However new (or updated) plugins can use the new FinderIndexerResult::addNestedTaxonomy()
method to add nested taxonomies. This method gets a node object as a parameter, which has to implement at least the ImmutableNodeInterface interface, that is introduced with this PR. Internally it iterates down the tree along its parents, adds each parent as a taxonomy node with the previous node as its parent. In the result object, we are now also storing the taxonomy ID so that we can lookup the right taxonomy again later. The taxonomy table has been changed to a nested set table.
How to test?
Apply these changes and make sure that the DB changes are applied, too. Then clear the index and re-run the indexing. You can then see the category filter in the frontend having a nested display, as well as in the backend. Check the taxonomy table in the DB for the nested entries, too.
Check if it properly filters for the respective taxonomies in the frontend when searching.
Enable displaying the taxonomies in the frontend and check that you can disable branches and single taxonomies and that those properly vanish from the filters and the result display. Create Search Filters in the backend and test those, too, if they properly honour the taxonomies.
Status of this PR
This PR is mostly working, but I'm not 100% confident that I caught all changes that are necessary. I think I'm now depending a bit on feedback from you.
Right now this depends on #23452 being merged first.