I was confused by this for a bit too. When testing with curl, I was outputting the header info into the browser and Link: appeared empty, but when I viewed Inspect Element > Elements, I found the links were actually there in the html. Just need to parse the headers and grab them. This thread helped but accepted answer didn't mention this directly so I wanted to emphasize.
I personally like how Facebook does it with concatenating a json pagination object to the end of the api response. Good step in the right direction though, it does work!
I am not a fan of the way the cursor-based pagination has been implemented but we have to live with this.
The documentation clearly missing two vital things to confuse developers.
1. If there are fewer results than the limit the Link header will not be present.
2. The Link header can't be shown in the browser. If this chain was not there I would never get to know this to inspect the header.
You have to isolate the request headers into a variable. If using Curl, something like CURLOPT_HEADER=>1 in the request. Look up some code to isolate curl header into a variable and then return it from a function.
$link_ex = explode( '<', $headers['Link'] );
$link_previous_ex = explode( '>;', $link_ex );
$link_next_ex = explode( '>;', $link_ex );
$link_previous = $link_previous_ex;
$link_next = $link_next_ex;
I am not a developer but trying to troubleshoot with my developer about why since implementing the new cursor-based pagination in our app, users can't search partially for products when filtering. Previously they could, and now I am considering reverting to the old api until this is figured out.
Is the solution shown here related in any way to our issue?
Hey I'm not 100% sure what you mean by "can't search partially for products when filtering", but maybe Shopify's predictive search api will help:
I think using the products endpoint for search would be very inefficient if you have a lot of products, although it's doable. There are a lot of solutions I'm sure your dev should be able to come up.
Couple solutions off top of my head - store all the products in your own database and maintain updates with daily syncs from Shopify - perform your existing call with all products as response. Or you could technically call the products endpoint, loop through all of the pages, store search matches in memory and return, but this again would be pretty inefficient. Or again you could sever filtering from search and use the predictive search api for the search portion. Again not really sure what you're trying to accomplish but I've actually gone with my own database that syncs daily and it has been very useful for a lot of other things.
Our app is backend. We allow users to apply bulk price updates to their products. They first need to search and filter through to find the products they want to update. Before they could search 'Blue' and the search would bring up all products with 'blue' in the title. Now that doesn't work.
We are using REST API.