From d3a5c9695c04826fbb89357f17ddf1cfbff1b6b5 Mon Sep 17 00:00:00 2001 From: Lachlan Turner Date: Wed, 20 Nov 2024 10:59:04 +1030 Subject: [PATCH 1/2] Handle null response from uploading file to Fredhopper --- src/export/Model/UploadExport.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/export/Model/UploadExport.php b/src/export/Model/UploadExport.php index d8656b2..0251dc7 100644 --- a/src/export/Model/UploadExport.php +++ b/src/export/Model/UploadExport.php @@ -66,6 +66,10 @@ public function execute(ExportInterface $export): void } else { $dataId = $this->dataIntegrationClient->uploadFasData($zipFileName); } + if ($dataId === null) { + $this->logger->error(__METHOD__ . ': Error uploading export to Fredhopper'); + return; + } $export->setDataId($dataId); $export->setStatus(ExportInterface::STATUS_UPLOADED); $this->exportResource->save($export); From d6e518a03310945f49efca1857a562798d0ec912 Mon Sep 17 00:00:00 2001 From: Lachlan Turner Date: Wed, 20 Nov 2024 16:50:57 +1030 Subject: [PATCH 2/2] Add more detail to debug logging of API requests --- src/export/Model/Api/DataIntegrationClient.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/export/Model/Api/DataIntegrationClient.php b/src/export/Model/Api/DataIntegrationClient.php index 53b2533..7fca6cf 100644 --- a/src/export/Model/Api/DataIntegrationClient.php +++ b/src/export/Model/Api/DataIntegrationClient.php @@ -12,8 +12,6 @@ use Magento\Framework\Filesystem\Io\File; use Psr\Log\LoggerInterface; -use function PHPUnit\Framework\stringStartsWith; - class DataIntegrationClient { @@ -305,10 +303,14 @@ private function sendRequest(Request $request): array $auth = $this->getAuth(); $this->httpClient->setAuth($auth['username'], $auth['password']); + if ($this->generalConfig->getDebugLogging()) { + $this->logger->debug("Request: " . $request->renderRequestLine()); + $this->logger->debug("Request headers:\n" . $request->getHeaders()->toString()); + } $response = $this->httpClient->send($request); if ($this->generalConfig->getDebugLogging()) { - $this->logger->debug("Request response:\n $response"); + $this->logger->debug("Request response:\n" . $response->toString()); } // clear client for next request $this->httpClient->reset();