Complementary query hooks
Secondary query hooks work independently or in the presence of query hooks that populate widgets. You can use them to retrieve supplementary data for a variety of use cases.
useSearchResultsBreadcrumb
You can use this hook on product listing pages to complement the useSearchResults
hook, it returns the taxonomy for the host page. Sorted in the order they appear in the URL, each item represents a URL segment.
The hook returns the following:
[
{
"category_id": "<id for item 0>",
"name": "<Name for item 0>",
"url_path": "<path for item 0>"
},
...
{
"category_id": "<id for item N>",
"name": "<Name for item N>",
"url_path": "<path for item N>"
}
]
In the UI reference site, in the Templates section, in SearchResults, the SearchResultsRowGrid demo uses this query hook.
useSearchResultsIsSelectedFacet
You can use this hook to complement the useSearchResults
hook. It returns true
if a facet has been selected in the search result widget.
boolean // true if a facet has been selected in the search results widget on the page
useSearchResultsSelectedFacets
You can use this hook to complement the useSearchResults
hook to retrieve additional information about the facets selected in the search results widget.
The hook returns the following where each item is a selected facet:
[
{
id: string,
name: string,
numberOfProducts: number,
values: [
{
id: string,
text: string
}
]
}
]
A page can contain only one search results widget. At runtime, this query hook recognizes the useSearchResults
hook on the page.