next to implement automatic refetch via cron
This commit is contained in:
1 parent
2eef682859
commit
77f8d034aa
4 files changed
+40
-7
No files matched your search
@@ -130,11 +130,32 @@ class EcomZoneAPI
|
||||
}
|
||||
}
|
||||
|
||||
public function getCatalog($perPage = 10)
|
||||
public function getCatalog($perPage = 1000)
|
||||
{
|
||||
$this->checkRateLimit();
|
||||
$url = $this->apiUrl . '/catalog';
|
||||
return $this->makeRequest('GET', $url, ['per_page' => $perPage]);
|
||||
$allProducts = [];
|
||||
$currentPage = 1;
|
||||
|
||||
do {
|
||||
$params = [
|
||||
'per_page' => $perPage,
|
||||
'page' => $currentPage
|
||||
];
|
||||
|
||||
$response = $this->makeRequest('GET', $url, $params);
|
||||
|
||||
if (isset($response['data']) && is_array($response['data'])) {
|
||||
$allProducts = array_merge($allProducts, $response['data']);
|
||||
}
|
||||
|
||||
$currentPage++;
|
||||
// Check if there's a next page
|
||||
$hasNextPage = isset($response['next_page_url']) && $response['next_page_url'] !== null;
|
||||
|
||||
} while ($hasNextPage);
|
||||
|
||||
return ['data' => $allProducts];
|
||||
}
|
||||
|
||||
public function getProduct($sku)
|
||||
|
||||
Reference in new issue
Block a user