Files
apimacro/app/Http/Controllers/TestPaoController.php

40 lines
955 B
PHP
Raw Normal View History

2024-05-16 19:27:26 +02:00
<?php
namespace App\Http\Controllers;
2024-06-15 17:28:29 +02:00
use Codexshaper\WooCommerce\Facades\Product;
2024-05-16 19:27:26 +02:00
use Illuminate\Support\Facades\Artisan;
class TestPaoController extends Controller
{
public function runTestPao()
{
try {
echo "run";
Artisan::call('product:testpao', []);
} catch (\Exception $e) {
// Log or handle the exception here
}
}
public function provapao()
{
$this->runTestPao();
echo "Test OK!";
}
2024-06-15 17:28:29 +02:00
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);
}
}
2024-05-16 19:27:26 +02:00
}