54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
|
|
<?php
|
|
if (!defined("_PS_VERSION_")) {
|
|
exit();
|
|
}
|
|
|
|
class EcomZoneApiTest
|
|
{
|
|
private $client;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->client = new EcomZoneClient();
|
|
}
|
|
|
|
public function testProductFetch()
|
|
{
|
|
try {
|
|
// Get first page with one product
|
|
$result = $this->client->getCatalog(1, 1);
|
|
|
|
EcomZoneLogger::log("API Test Result", "INFO", [
|
|
"result" => $result,
|
|
]);
|
|
|
|
return $result;
|
|
} catch (Exception $e) {
|
|
EcomZoneLogger::log("API Test Failed", "ERROR", [
|
|
"error" => $e->getMessage(),
|
|
]);
|
|
throw $e;
|
|
}
|
|
}
|
|
public function getProducts($page = 1, $perPage = 10)
|
|
{
|
|
try {
|
|
$result = $this->client->getCatalog($page, $perPage);
|
|
|
|
return [
|
|
"products" => $result["data"] ?? [],
|
|
"total" => $result["total"] ?? 0,
|
|
"current_page" => $page,
|
|
"per_page" => $perPage,
|
|
];
|
|
} catch (Exception $e) {
|
|
EcomZoneLogger::log("Failed to get products", "ERROR", [
|
|
"error" => $e->getMessage(),
|
|
]);
|
|
throw $e;
|
|
}
|
|
}
|
|
}
|
|
|