phpclassic / php-shopify

PHP SDK for Shopify API
Apache License 2.0
570 stars 210 forks source link

Add support for cursor based pagination (again) #136

Closed rjacobso closed 4 years ago

rjacobso commented 4 years ago

This is an attempt to implement the same logic from #125 but without breaking backwards-compat.

hippoduck commented 4 years ago

What is the correct way to use this to get all products? I used your example code on your other PR, but I get the following error:

No action named lastResourceContainsNextPageInfo is defined for Product in ....

rjacobso commented 4 years ago

You are correct, it seems there was another competing pull request to do this in a different manner. It looks like @tareqtms approved both, but some / most of my changes were removed as part of the merge. - Actually this could have been me screwing it up trying to bring my repo up to date. Looking now ...

tareqtms commented 4 years ago

The working code should be here:

$productResource =  $shopify->Product();
$products = $productResource->get(['limit'=>50]);
$nextPageProducts = $productResource->get($productResource->getNextPageParams());
/* in short: you need to reuse the resource to get the params before making another resource */**

Please follow the thread #101 for more info.