From cfed084093e06a122d962738eccc1c70e070ee71 Mon Sep 17 00:00:00 2001 From: robertsaternus Date: Thu, 12 Feb 2026 10:52:42 +0100 Subject: [PATCH] INT-221: predictivebasket example for kastner --- src/Model/Api/Example.php | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/Model/Api/Example.php diff --git a/src/Model/Api/Example.php b/src/Model/Api/Example.php new file mode 100644 index 00000000..b2c4b25e --- /dev/null +++ b/src/Model/Api/Example.php @@ -0,0 +1,55 @@ + $item->getProduct()->getSku(), + $this->checkoutSession->getQuote()->getItems() ?? [] + ); + + $baseParams = [ + 'idsOnly' => true, + 'userId' => $this->sessionData->getUserId(), + ]; + + $queryString = http_build_query($baseParams, '', '&', PHP_QUERY_RFC3986); + + foreach ($cartSkus as $sku) { + $queryString .= '&blacklist=' . rawurlencode($sku); + } + + $client = $this->clientBuilder + ->withServerUrl($this->communicationConfig->getAddress()) + ->withApiKey($this->authConfig->getApiKey()) + ->withVersion($this->communicationConfig->getVersion()) + ->build(); + + $result = $client->request( + 'GET', + 'rest/v5/predictivebasket/dev_kastner?' . $queryString + ); + + return array_column($result['hits'] ?? [], 'id'); + } +}