-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to paginate orders #60
Comments
Did you solve this? I'm currently working on upgrading my script to use pagination. Here's my code - it runs fine, but for some reason is returning no orders in my testing. It might help you, and if you've already solved it, I'm curious how you did it.
|
I tried that and had the same issue, couldn't debug further to figure out the issue in the package, has a bit of a time crunch. I had to write my own function to get the https://shopify.dev/tutorials/make-paginated-requests-to-rest-admin-api Here is the function that I created, hope it helps to fix the issue: /**
* Gets next page info string for use in pagination
*
* @param $headerLine
*
* @return string
*/
public function parseNextPageInfo($headerLine)
{
if ($headerLine) {
$matchData = [];
if (preg_match("/<([^>]*)>; rel=\"next\"/", $headerLine, $matchData)) {
// found rel="next"
$query = parse_url($matchData[1], PHP_URL_QUERY);
$pairs = explode("&", $query);
foreach ($pairs as $p) {
[
$key,
$value,
] = explode("=", $p);
if ($key == "page_info") {
return $value;
}
}
}
}
return false;
}
public function hasNextPageInfo()
{
return !empty($this->getNextPageInfo());
}
public function getNextPageInfo()
{
return $this->parseNextPageInfo($this->client->getLastResponse()->getHeaderLine('Link'));
} |
I think it should be:
|
Bob - I think you're right about the status=any addition. I've also tested that but had no luck. Since I posted this comment I've done a lot of troubleshooting and I'm getting the same empty result set even when I hit the API directly with curl. I've found a group of users reporting the same issue - I think it is a Shopify API issue not a slince/shopify-api-php issue. |
The issue was not with slince/shopify-api-php - it was due to a change in the Shopify Order API. My app was configured as a sales channel and they changed the API response to only return orders made through my app. I worked with a Shopify rep to remove the sales channel privilege from my app (not reversible) and I now have access to 60 days of orders. |
Hello In version 2.4.1, you can get page info like this $nextPageInfo = $pagination->getNextPageInfo();
$prevPageInfo = $pagination->getPrevPageInfo();
$products = $pagination->current($nextPageInfo); |
It is awesome! Thank you so much @slince. |
I am using the API version
2020-01
. How do I go about paginating the orders?Here is the code I have so far
Not quite sure, how to proceed after this.
The text was updated successfully, but these errors were encountered: