Skip to content

Commit

Permalink
ApiReader: Bugfix for search_after
Browse files Browse the repository at this point in the history
  • Loading branch information
J0rdyV committed Mar 19, 2024
1 parent 4244f44 commit 7bf6f49
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Component/Akeneo/Client/ApiReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ private function request($endpoint = false): array

$items = [];
if (isset($this->context['filters']) && !empty($this->context['filters'])) {
$endpoint = sprintf('%s?search=', $endpoint);
if ($this->endpoint instanceof ApiProductModelsEndpoint || $this->endpoint instanceof ApiProductsEndpoint) {
$endpoint = sprintf('%s?pagination_type=search_after&search=', $endpoint);
} else {
$endpoint = sprintf('%s?search=', $endpoint);
}
foreach ($this->context['filters'] as $attrCode => $filterValues) {
$valueChunks = array_chunk(array_values($filterValues),100);
foreach ($valueChunks as $filterChunk) {
Expand Down Expand Up @@ -86,8 +90,20 @@ private function request($endpoint = false): array
return $items;
}

$url = $this->client->getUrlGenerator()->generate($endpoint);
if ($this->endpoint instanceof ApiProductModelsEndpoint || $this->endpoint instanceof ApiProductsEndpoint) {
if(isset($this->context['limiters']['querystring'])) {
$url = sprintf('%s&pagination_type=search_after', $url);
} else {
$url = sprintf('%s?pagination_type=search_after', $url);
}
}

//dd($url, $endpoint, $this->context['limiters']);

$items = $this->client
->get($this->client->getUrlGenerator()->generate($endpoint))
//->get($this->client->getUrlGenerator()->generate($endpoint))
->get($url)
->getResponse()
->getContent();

Expand Down

0 comments on commit 7bf6f49

Please sign in to comment.