From 7235bfdecebaefcc750202dfde62e092f34f3737 Mon Sep 17 00:00:00 2001 From: Marko <52066939+HeX87@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:27:05 +0100 Subject: [PATCH] add fixed export --- .../ExportHiltesSubscriber.php | 4 ++++ src/EventSubscriber/SlackNotifySubscriber.php | 4 ++-- src/Helper/Hiltes.php | 21 ++++++++----------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/EventSubscriber/ExportHiltesSubscriber.php b/src/EventSubscriber/ExportHiltesSubscriber.php index 5ddc898..f0091af 100644 --- a/src/EventSubscriber/ExportHiltesSubscriber.php +++ b/src/EventSubscriber/ExportHiltesSubscriber.php @@ -16,6 +16,10 @@ class ExportHiltesSubscriber implements EventSubscriberInterface { } + /** + * @param ViewEvent $event + * @return void + */ public function onPatchOrder(ViewEvent $event): void { $method = $event->getRequest()->getMethod(); diff --git a/src/EventSubscriber/SlackNotifySubscriber.php b/src/EventSubscriber/SlackNotifySubscriber.php index 8d3baf5..209fc64 100644 --- a/src/EventSubscriber/SlackNotifySubscriber.php +++ b/src/EventSubscriber/SlackNotifySubscriber.php @@ -40,7 +40,7 @@ class SlackNotifySubscriber implements EventSubscriberInterface { $slack = new Client($this->slackWebhookUrl, [ 'username' => 'CDS-Notify', - 'channel' => '#general', + 'channel' => '#online-verkäufe', 'link_names' => true, 'icon' => ':robot_face:', 'allow_markdown' => true, @@ -56,7 +56,7 @@ class SlackNotifySubscriber implements EventSubscriberInterface $msg = "Bestellung {$order->getOrderId()}: \n"; - foreach ($order->getData() as $item) { + foreach ($order->getData()[0]['positions'] as $item) { if ($item['menge'] > 0 && strlen($item['sku']) > 0) { $msg .= $item['name']; $msg .= ' ' . $item['sku']; diff --git a/src/Helper/Hiltes.php b/src/Helper/Hiltes.php index aca0205..4c704ad 100644 --- a/src/Helper/Hiltes.php +++ b/src/Helper/Hiltes.php @@ -241,28 +241,21 @@ class Hiltes public function sendToHiltes($url, $param, $auth = false) { - if ($auth) { - #var_export($this->hiltesApiHash); - #var_export($url); - #var_export($param); - - } - $ch = curl_init($url); if ($auth) { $authorization = "Authorization: Bearer " . $this->hiltesApiHash; } else { $authorization = false; } -#dump($param); -# Setup request to send json via POST. + + # Setup request to send json via POST. $payload = json_encode($param); -#dump($payload); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', $authorization)); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); -# Return response instead of printing. + # Return response instead of printing. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -# Send request. + # Send request. $result = curl_exec($ch); curl_close($ch); return $result; @@ -355,6 +348,10 @@ class Hiltes return $arr; } + /** + * @param $data + * @return bool + */ public function sendOrderToHiltes($data) { $url = $this->hiltesApiUrl . '/api/WebSale/import';