Ad

Only One Page Of Product Got With Rest Admin Api

- 1 answer

I have so many pages of products on my development store.But when I try to use products.json to get all of my products, it only take 50 listings(one page).Could anybody solve my doubt?

<?php
 $url = 'https://myshopifystore/admin/api/2019-07/products.json';
 $result = file_get_contents($url);
 $data = json_decode($result, true);
 dd($data);

my result like this picture:

Ad

Answer

The limit property on the request has a default of 50 up to 250. In case you want more use a loop to search though every page until the end.

GET /admin/api/2019-07/products.json?limit=250?page=1

Use

GET /admin/api/2019-07/products/count.json 

to get the total product you want to search.

More info about paginated page here

EDIT 1 : The paginated ?page= is now deprecated. It will be remove in version 2020-07. You should use cursor-based pagination.

Ad
source: stackoverflow.com
Ad