This commit is contained in:
paoloar77
2024-06-15 17:28:29 +02:00
parent fe6fc93da6
commit 89e0bdb153
2 changed files with 19 additions and 0 deletions

View File

@@ -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);
}
}
}

View File

@@ -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']);