Skip to content

Commit c778b8c

Browse files
author
Avatarsia
committed
fix(woocommerce): catch batch request exceptions, log success at info level
processBatchResponse()-Aufrufe sind jetzt in try/catch eingeschlossen — ein einzelner WC-Batch mit HTTP 5xx/Timeout bricht den Sync nicht mehr ab, nachfolgende Chunks werden trotzdem verarbeitet. Der Erfolgs-Log in processBatchResponse() nutzt jetzt ->info() statt ->error() (war falscher Log-Level). Spotted by review of b96079b.
1 parent 8da9331 commit c778b8c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

www/pages/shopimporter_woocommerce.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -663,16 +663,24 @@ public function ImportSendListLager()
663663

664664
// Simple products
665665
foreach (array_chunk($simpleItems, 100) as $chunk) {
666-
$response = $this->client->post('products/batch', ['update' => $chunk]);
667-
$anzahl += $this->processBatchResponse($response, 'products/batch');
666+
try {
667+
$response = $this->client->post('products/batch', ['update' => $chunk]);
668+
$anzahl += $this->processBatchResponse($response, 'products/batch');
669+
} catch (Exception $e) {
670+
$this->logger->error('WooCommerce Batch-Request fehlgeschlagen fuer products/batch: ' . $e->getMessage());
671+
}
668672
}
669673

670674
// Variations (one batch endpoint per parent product)
671675
foreach ($variationItems as $parentId => $items) {
672676
foreach (array_chunk($items, 100) as $chunk) {
673677
$endpoint = 'products/' . $parentId . '/variations/batch';
674-
$response = $this->client->post($endpoint, ['update' => $chunk]);
675-
$anzahl += $this->processBatchResponse($response, $endpoint);
678+
try {
679+
$response = $this->client->post($endpoint, ['update' => $chunk]);
680+
$anzahl += $this->processBatchResponse($response, $endpoint);
681+
} catch (Exception $e) {
682+
$this->logger->error('WooCommerce Batch-Request fehlgeschlagen fuer ' . $endpoint . ': ' . $e->getMessage());
683+
}
676684
}
677685
}
678686

@@ -707,7 +715,7 @@ private function processBatchResponse($response, $endpoint)
707715
"WooCommerce Batch-Fehler ($endpoint) fuer ID {$item->id}: [$code] $message"
708716
);
709717
} else {
710-
$this->logger->error(
718+
$this->logger->info(
711719
"WooCommerce Lagerzahlenübertragung (Batch) fuer Artikel-ID {$item->id} erfolgreich",
712720
['endpoint' => $endpoint]
713721
);

0 commit comments

Comments
 (0)