diff --git a/app/Http/Controllers/TestPaoController.php b/app/Http/Controllers/TestPaoController.php index 3c9662e9..7bad3f2f 100644 --- a/app/Http/Controllers/TestPaoController.php +++ b/app/Http/Controllers/TestPaoController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use Codexshaper\WooCommerce\Facades\Product; use Illuminate\Support\Facades\Artisan; class TestPaoController extends Controller @@ -21,4 +22,18 @@ class TestPaoController extends Controller $this->runTestPao(); echo "Test OK!"; } + + public function getProductBySku($sku) + { + // Estrai il prodotto utilizzando il codice SKU + $product = Product::where('sku', $sku)->first(); + + if ($product) { + // Ritorna il prodotto trovato come JSON + return response()->json($product); + } else { + // Ritorna un errore se il prodotto non รจ trovato + return response()->json(['error' => 'Product not found'], 404); + } + } } diff --git a/routes/web.php b/routes/web.php index c587a846..13efe568 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6205,3 +6205,7 @@ Route::get('/handle-article-action-pao/{id}/{action}', function ($id, $action) { return "Azione non supportata"; } })->name('handleArticleActionPao'); + + +Route::get('/product/{sku}', [TestPaoController::class, 'getProductBySku']); +