slince / shopify-api-php

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

How I can get header pagination for searches. #45

Closed camilo300792 closed 4 years ago

camilo300792 commented 4 years ago
#...
Link: "<https://{shop}.myshopify.com/admin/api/{version}/products.json?page_info={page_info}&limit={limit}>; rel={next}, <https://{shop}.myshopify.com/admin/api/{version}/products.json?page_info={page_info}&limit={limit}>; rel={previous}"
#...

The link header includes a rel parameter, where relation-types describes the relation of the linked page to the current page of results. The value can either be previous or next.

The URL in the link header can include up to two parameters:

page_info: A unique ID used to access a certain page of results. The page_info parameter can't be modified and must be used exactly as it appears in the link header URL.
limit: The maximum number of results to show on the page.

A request that includes the page_info parameter can't include any other parameters except for limit. If you want your results to be filtered by other parameters, then you need to include those parameters in the first request you make.

camilo300792 commented 4 years ago
protected function buildUrl($resource)
{
        # return sprintf('https://%s/admin/%s.json', $this->shop, $resource);
        return sprintf('https://%s/admin/api/2019-10/%s.json', $this->shop, $resource);
}
slince commented 4 years ago

see #46