Create a request to get product listing page data
This topic shows you how to make a call to the Sitecore Discover Search and Recommendation API to get product listing page (PLP) data in the following scenario:
-
You want to show 24 results on a PLP (
n_item= 24). -
You want to make a call to get data for the first page of the PLP (
page_number=1). -
You want all facets.
-
The user must be able to sort products by customer ratings.
Use the API explorer to try out requests and see sample responses.
To create a request to get PLP data:
-
In the header, add cookies and, if required, authentication details.
-
In the request body, add page context and user context. For page context, include the page
uriand locale information (if applicable). For user context, include either theuuidor theuser_ID.RequestResponse{ "context": { "page": { "uri": "/womens/memory-foam" }, "user": { "uuid": "sampleUUID" } } } -
Add widget information. Here, we want all widgets.
RequestResponse{ "widget": { "all": true } } -
Add pagination information. Specify the number of items (
n_item) you want to see in one page of search results. Also, specify the page (page_number) you are making the call for.RequestResponse{ "n_item": 24, "page_number": 1 } -
Add facet information to tell Discover how many facets you want. Here, we want all facets.
RequestResponse{ "facet": { "all": true }, } -
Add sort information to tell Discover how you want to sort. Here, we want the customer to sort products by ratings in descending order.
RequestResponse{ "sort": { "value": [ { "name": "rating", "order": "desc" } ] } } -
Request product content. Here, we want the entire product.
RequestResponse{ "content": { "product": {} } }
You can see the complete request with all objects put together and the corresponding response in the sample section.