#community-help

Calculating Total Pages in Search Request Results

TLDR Laura asked how to calculate total pages of search results. Jason suggested using found / per_page.

Powered by Struct AI
+11
4
3mo
Solved
Join the chat
Jun 09, 2023 (3 months ago)
Laura
Photo of md5-e31442d4d6c849124582a10193fe7721
Laura
05:21 PM
Is it possible for my search request to return the total pages of my results? I realized that the request returns the total of items and the current page, but to dentify in my front end the page I am on I need to implement some logic with the total of products and the page I am on?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:22 PM
If you do found / per_page you should get the total number of pages
05:22
Jason
05:22 PM
per_page is a search parameter that defaults to 10
Laura
Photo of md5-e31442d4d6c849124582a10193fe7721
Laura
05:25 PM
Thanks! I understood now
+11