I have a problem connecting to Magento API 2.4. I use the Client from the Laminas framework for this. I would like to limit the amount of data returned by the API (I use "fields") and limit the amount of "items" by filtering with the "updated_at" field.
I will add that the basic CURL is working properly.
My code:
$updatedAt = '2021-07-12 07:12:24';
$query = [
'searchCriteria' => [
'pageSize' => $pageSize,
'currentPage' => $currentPage,
'filterGroups' => [
0 => [
'filters' => [
0 => [
'conditionType' => 'eq',
'field' => 'type_id',
'value' => 'simple'
]
]
]
]
]
//todo: Filter by 'fields' key
];
if (is_string($updatedAt)) {
$query['searchCriteria']['filterGroups'][100]['filters'][100]['conditionType'] = 'gteq';
$query['searchCriteria']['filterGroups'][100]['filters'][100]['field'] = 'updated_at';
$query['searchCriteria']['filterGroups'][100]['filters'][100]['value'] = $updatedAt;
}
$this->sortQuery($query);
$uri = new Http($this->baseUrl . $resource);
$client = new Client();
$client->setMethod('GET');
$client->setOptions($this->options);
$client->setHeaders(
[
'Authorization' => $this->authorization->getAuthorization('GET', $uri->toString(), $query)
]
);
$client->setUri($uri->toString() . '?' . http_build_query($query, "", "&", PHP_QUERY_RFC3986));
$response = $client->send();