Skip to content

Commit eece74e

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 55ba123 commit eece74e

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
@@ -607,16 +607,24 @@ public function ImportSendListLager()
607607

608608
// Simple products
609609
foreach (array_chunk($simpleItems, 100) as $chunk) {
610-
$response = $this->client->post('products/batch', ['update' => $chunk]);
611-
$anzahl += $this->processBatchResponse($response, 'products/batch');
610+
try {
611+
$response = $this->client->post('products/batch', ['update' => $chunk]);
612+
$anzahl += $this->processBatchResponse($response, 'products/batch');
613+
} catch (Exception $e) {
614+
$this->logger->error('WooCommerce Batch-Request fehlgeschlagen fuer products/batch: ' . $e->getMessage());
615+
}
612616
}
613617

614618
// Variations (one batch endpoint per parent product)
615619
foreach ($variationItems as $parentId => $items) {
616620
foreach (array_chunk($items, 100) as $chunk) {
617621
$endpoint = 'products/' . $parentId . '/variations/batch';
618-
$response = $this->client->post($endpoint, ['update' => $chunk]);
619-
$anzahl += $this->processBatchResponse($response, $endpoint);
622+
try {
623+
$response = $this->client->post($endpoint, ['update' => $chunk]);
624+
$anzahl += $this->processBatchResponse($response, $endpoint);
625+
} catch (Exception $e) {
626+
$this->logger->error('WooCommerce Batch-Request fehlgeschlagen fuer ' . $endpoint . ': ' . $e->getMessage());
627+
}
620628
}
621629
}
622630

@@ -651,7 +659,7 @@ private function processBatchResponse($response, $endpoint)
651659
"WooCommerce Batch-Fehler ($endpoint) fuer ID {$item->id}: [$code] $message"
652660
);
653661
} else {
654-
$this->logger->error(
662+
$this->logger->info(
655663
"WooCommerce Lagerzahlenübertragung (Batch) fuer Artikel-ID {$item->id} erfolgreich",
656664
['endpoint' => $endpoint]
657665
);

0 commit comments

Comments
 (0)