1

We are using Sitecore 9.0.2, SXA 1.8.1 and Azure search.

The SXA component Search Box works perfectly fine. In our application, we need to show the search results from other application along with the OOTB search results. In order to search in other application, an API is exposed which we can use to extract data in JSON format.

We want to merge this data with Sitecore search result and display as a common result. I am planning to clone the search box component and write a custom controller. Not sure which method to overwrite to obtain the above functionality.

Any idea which method to overwrite or is there a better way to do this?

1 Answer 1

1

Search Box rendering has nothing to do with this. Take a look at SearchController (Sitecore.XA.Feature.Search). The GetResults() method is responsible for returning results to the browser.

You have two options:

  • override SearchController and GetResults() method and call your custom search API next to GetItems() method. Then you will need to convert the JSON you mention into objects of type Sitecore.XA.Feature.Search.Models.Result. This is not an easy approach but achievable!
  • try to use a new pipeline which has been introduced in 1.8.1 called processSearchItems. This pipeline has been initially created to enrich already found items with additional models (custom objects). But the arguments which are passed to this pipeline has the whole list of results - you can extend that list with items from your custom search API (search phrase from a Search Box can be obtained from HTTP Request parameters in any place).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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