From 4f889d93305e7401efc4395cba7940e9e816f679 Mon Sep 17 00:00:00 2001 From: Paolo A Date: Wed, 14 Aug 2024 15:33:35 +0000 Subject: [PATCH] Comm2 --- app/Console/Commands/CheckProductBySku.php | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/Console/Commands/CheckProductBySku.php diff --git a/app/Console/Commands/CheckProductBySku.php b/app/Console/Commands/CheckProductBySku.php new file mode 100644 index 00000000..7b807493 --- /dev/null +++ b/app/Console/Commands/CheckProductBySku.php @@ -0,0 +1,39 @@ +argument('sku'); + + try { + // Recupera i prodotti per lo SKU specificato + $products = Product::where('sku', $sku)->get(); + + if ($products->isNotEmpty()) { + // Mostra l'ID del primo prodotto se viene trovato + $this->info('Connection successful! Product ID: ' . $products[0]->id); + } else { + $this->error('No products found with SKU: ' . $sku); + } + } catch (\Exception $e) { + // Gestisce eventuali errori di connessione + $this->error('Error: ' . $e->getMessage()); + } + } +}