How to use paginate function in getting products?

Highlighted
Shopify Partner
12 0 1

I want to use paginate function in App page.

I saw the URL below.

https://help.shopify.com/en/api/guides/paginated-rest-results

 

And I tried to get 3 products with the code below.

But I could get all products, not 3 products.

 

$products = $shopify->get("/admin/api/2019-07/products.json?limit=3");

dd($products);

 Could someone give me any advise please?

0 Likes
Highlighted
Shopify Partner
12 0 1

I solve the problem. That was my mistake.

$products = $shopify->get("/admin/api/2019-07/products.json",["limit"=>3]);

and it worked, and I got 3 products.

 

But I have another problem.

I got header request below.

 Link 

"<https://xxxxxx.myshopify.com/admin/api/2019-07/products.json?limit=3&page_info=abcdefg>; rel="next"

 So, I tried like this

$products = $shopify->get("/admin/api/2019-07/products.json",["limit"=>3, "page_info"=>"abcdefg"]);

 but I got error below.

{"page_info":"Invalid value."}

 

As for 2019-04 version, "page" work like this.

$products = $shopify->get("/admin/api/2019-04/products.json",["limit"=>3, "page"=>1]);

 

But not in 2019-07 version. I want to use 2019-07 version.

 

Could someone give me some advise  please?

1 Like