Trigger n8n flows for Shopify imports

This commit is contained in:
2026-08-12 18:03:59 +02:00
parent 727025da88
commit ce0001e583
2 changed files with 108 additions and 0 deletions
@@ -3,6 +3,7 @@ declare(strict_types=1);
require_once __DIR__ . '/../../../modules/shared/db.php';
require_once __DIR__ . '/shopify-api.php';
require_once __DIR__ . '/service.php';
require_once __DIR__ . '/../bestellungen/shopify-projection.php';
function shopify_delta_argument(string $name, array $argv, ?string $default = null): ?string
@@ -133,6 +134,16 @@ function run_shopify_delta(array $env, PDO $pdo, string $cutoff, bool $dryRun):
static fn (string $gid): array => shopify_delta_load_order($env, $gid),
$dryRun
);
if (!$dryRun && ($result['status'] ?? '') === 'imported') {
$labelPayload = build_legacy_label_order_payload($pdo, (int) $result['sales_order_id']);
$labelResult = trigger_shipping_label_flow($labelPayload, $env);
$excelResult = trigger_excel_webhook((string) ($summaryOrder['name'] ?? $orderGid), $env);
$result['label_trigger'] = $labelResult;
$result['excel_trigger'] = $excelResult;
if (!$labelResult['ok'] || !$excelResult['ok']) {
throw new RuntimeException('Mindestens ein n8n-Webhook ist fehlgeschlagen');
}
}
if (($result['status'] ?? '') === 'already_imported') {
$counters['already_imported']++;
} else {