Skip to content

Commit

Permalink
SHOP-3316: Add Paginated Order Calls
Browse files Browse the repository at this point in the history
  • Loading branch information
DevBoldHarry committed Jun 21, 2024
1 parent e1458e5 commit 454e657
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Services/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,29 @@ public function getByParams($params)
return new Collection($orders);
}

/**
* @return Collection
*/
public function getByParamsWithPagination(array $params): Collection
{
$allOrders = [];
$nextPageInfo = '';

do {
$orders = $this->client->get('admin/orders.json', $params);

foreach ($orders['orders'] as $order) {
$allOrders[count($allOrders)] = $this->unserializeModel($order, ShopifyOrder::class);
};

$pageInfo = $this->client->getPageInfo();
$nextPageInfo = $pageInfo->getNext();
$params['page_info'] = $nextPageInfo;
} while (!empty($nextPageInfo));

return new Collection($allOrders);
}

/**
* @param array $filter
*
Expand Down

0 comments on commit 454e657

Please sign in to comment.