22
33namespace Picqer \Shopware6Plugin \Subscriber ;
44
5- use Exception ;
65use Picqer \Shopware6Plugin \Client \PicqerClient ;
76use Picqer \Shopware6Plugin \Exception \IncompleteConfigurationException ;
87use Picqer \Shopware6Plugin \Exception \RequestFailedException ;
@@ -62,24 +61,23 @@ public function pushOrder(EntityWrittenEvent $event): void
6261 return ;
6362 }
6463
65- $ debug = false ;
66- try {
67- $ order = $ this ->orderRepository ->search (new Criteria ([$ event ->getIds ()[0 ]]), $ event ->getContext ())->first ();
68- if (! $ order instanceof OrderEntity) {
69- return ;
70- }
64+ $ order = $ this ->orderRepository ->search (new Criteria ([$ event ->getIds ()[0 ]]), $ event ->getContext ())->first ();
65+ if (! $ order instanceof OrderEntity) {
66+ return ;
67+ }
7168
72- $ salesChannelId = $ order ->getSalesChannelId ();
69+ $ salesChannelId = $ order ->getSalesChannelId ();
7370
74- $ disabled = $ this ->configService ->getBool ($ this ->buildConfigKey ('disabled ' ), $ salesChannelId );
75- if ($ disabled ) {
76- return ;
77- }
71+ $ disabled = $ this ->configService ->getBool ($ this ->buildConfigKey ('disabled ' ), $ salesChannelId );
72+ if ($ disabled ) {
73+ return ;
74+ }
7875
79- $ subdomain = $ this ->configService ->getString ($ this ->buildConfigKey ('subdomain ' ), $ salesChannelId );
80- $ connectionKey = $ this ->configService ->getString ($ this ->buildConfigKey ('connectionkey ' ), $ salesChannelId );
81- $ debug = $ this ->configService ->getBool ($ this ->buildConfigKey ('debug ' ), $ salesChannelId );
76+ $ subdomain = $ this ->configService ->getString ($ this ->buildConfigKey ('subdomain ' ), $ salesChannelId );
77+ $ connectionKey = $ this ->configService ->getString ($ this ->buildConfigKey ('connectionkey ' ), $ salesChannelId );
78+ $ debug = $ this ->configService ->getBool ($ this ->buildConfigKey ('debug ' ), $ salesChannelId );
8279
80+ try {
8381 if (empty ($ subdomain ) || empty ($ connectionKey )) {
8482 throw new IncompleteConfigurationException ($ subdomain , $ connectionKey );
8583 }
@@ -97,6 +95,8 @@ public function pushOrder(EntityWrittenEvent $event): void
9795 $ this ->logger ->error ('[Picqer] Subdomain and/or connection-key not configured ' , [
9896 'subdomain ' => $ e ->getSubdomain (),
9997 'connectionKey ' => $ e ->getConnectionKey (),
98+ 'orderId ' => $ order ->getId (),
99+ 'salesChannelId ' => $ salesChannelId ,
100100 ]);
101101 } catch (RequestFailedException $ e ) {
102102 if (! $ debug ) {
@@ -106,11 +106,8 @@ public function pushOrder(EntityWrittenEvent $event): void
106106 $ this ->logger ->error ('[Picqer] Could not call webhook ' , [
107107 'endpoint ' => $ e ->getEndpoint (),
108108 'message ' => $ e ->getMessage (),
109- ]);
110- } catch (Exception $ e ) {
111- $ this ->logger ->error ('[Picqer] Caught unexpected exception ' , [
112- 'exception ' => get_class ($ e ),
113- 'message ' => $ e ->getMessage (),
109+ 'orderId ' => $ order ->getId (),
110+ 'salesChannelId ' => $ salesChannelId ,
114111 ]);
115112 }
116113 }
0 commit comments