Magento – Add Pagination To Catalog Search Results REST API: Magento 2

apimagento2rest

I am using this API for search:

http://domain.com/index.php/rest/V1/search?searchCriteria[requestName]=quick_search_container&searchCriteria[filterGroups][0][filters][0][field]=search_term&searchCriteria[filterGroups][0][filters][0][value]=life

The response is:

– Total results is 7

I need to get results in pagination mode so I updated the API to become:

http://domain.com/index.php/rest/V1/search?searchCriteria[requestName]=quick_search_container&searchCriteria[filterGroups][0][filters][0][field]=search_term&searchCriteria[filterGroups][0][filters][0][value]=life&searchCriteria[current_page]=1&searchCriteria[page_size]=5

The response is:

– Total results is 5

– Current page is 1

If I changed the current page 2, the response supposed to be:

Total results is 2

– Current page is 2

But, I got the same result in the page 1.

Best Answer

rest/V1/products?searchCriteria[filterGroups][0][filters][0]
[field]=category_id&searchCriteria[filterGroups][0][filters][0]
[value]=7&searchCriteria[filterGroups][0][filters][0]
[conditionType]=eq&searchCriteria[sortOrders][0]
[field]=created_at&searchCriteria[sortOrders][0][direction]=DESC&searchCriteria[pageSize]=1&searchCriteria[currentPage]=4

Related Topic