slince / shopify-api-php

:rocket: Shopify API Client for PHP
MIT License
128 stars 48 forks source link

The page filter has been removed from multiple endpoints. Use cursor-based pagination instead. #46

Closed duskohu closed 4 years ago

duskohu commented 4 years ago

Hi, I use slince/shopify-api-php, shopify sent me mail. The page filter has been removed from multiple endpoints. Use cursor-based pagination instead. Deprecated in 2019-07 and support will be removed on April 1, 2020 version: ^2.1 How can I fix this problem? I use page for select data:

$query = ["published_status" => "published"];
$excludeTags = [];

$limit = 100;
 $productsCount = $client->getProductManager()->count($query);
$pages = ceil($productsCount / $limit);
$query["limit"] = $limit;

for ($i = 1; $i <= $pages; $i++) {
    $query["page"] = $i;
    /** @var Product[] $products */
    $products = $client->getProductManager()->findAll($query);
    foreach ($products as $product) {

    }
}
slince commented 4 years ago

hello, this is fixed in the latest version 2.4.0

slince commented 4 years ago

Please use $manager->paginate([xxx]) to generate CursorBasedPagination object

$pagination = $client->getProductManager()->paginate([
    // filter your product
    'limit' => 3,
    'created_at_min' => '2015-04-25T16:15:47-04:00'
]);
// $pagination is instance of `Slince\Shopify\Common\CursorBasedPagination`

$currentProducts = $pagination->current(); //current page

while ($pagination->hasNext()) {
    $nextProducts = $pagination->next();
}