Browse code

Implement search by sku api method

Benjamin Roth authored on20/10/2024 23:26:41
Showing1 changed files
... ...
@@ -116,4 +116,33 @@ class Shopware
116 116
 
117 117
         return false;
118 118
     }
119
+
120
+    public function getProductsForSku(string $strSku)
121
+    {
122
+        $options = [
123
+            'headers' => [
124
+                $this->getAuthentication(),
125
+                'Content-Type: application/json',
126
+                'Accept: application/json'
127
+            ],
128
+            'body' => json_encode([
129
+                'filter' => [
130
+                    [
131
+                        'type' => 'equals',
132
+                        'field' => 'productNumber',
133
+                        'value' => $strSku
134
+                    ]
135
+                ]
136
+            ])
137
+        ];
138
+
139
+        $response = $this->sendRequest('search/product',$options,'POST');
140
+
141
+        if ($response->getStatusCode() == 200)
142
+        {
143
+            return json_decode($response->getContent());
144
+        }
145
+
146
+        return false;
147
+    }
119 148
 }