add shopware store-api

This commit is contained in:
team 1
2026-04-09 12:00:34 +02:00
parent 0ef3b43b30
commit 1aee32f1d8
13 changed files with 992 additions and 10 deletions

View File

@@ -0,0 +1,72 @@
<?php
declare(strict_types=1);
namespace App\Command;
use App\Commerce\ShopSearchService;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand(name: 'mto:agent:test:shop-search')]
final class TestShopSearchCommand extends Command
{
public function __construct(
private readonly ShopSearchService $shopSearchService,
) {
parent::__construct();
}
protected function configure(): void
{
$this->addArgument(
'query',
InputArgument::OPTIONAL,
'Die zu testende Suchanfrage',
'zeige mir testomat modelle wasserhärte unter 5000 euro'
);
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$query = (string) $input->getArgument('query');
$output->writeln('Test query: ' . $query);
$output->writeln('');
$results = $this->shopSearchService->search($query);
if ($results === []) {
$output->writeln('Keine Shop-Ergebnisse gefunden.');
return Command::SUCCESS;
}
foreach ($results as $index => $result) {
$n = $index + 1;
$output->writeln(sprintf('[%d] %s', $n, $result->name));
$output->writeln(' ID: ' . $result->id);
$output->writeln(' Produktnummer: ' . ($result->productNumber ?? '-'));
$output->writeln(' Hersteller: ' . ($result->manufacturer ?? '-'));
$output->writeln(' Preis: ' . ($result->price ?? '-'));
$output->writeln(' Verfügbar: ' . ($result->available === null ? '-' : ($result->available ? 'ja' : 'nein')));
$output->writeln(' URL: ' . ($result->url ?? '-'));
$output->writeln(' Description: ' . ($result->description ?? '-'));
if ($result->highlights !== []) {
$output->writeln(' Highlights:');
foreach ($result->highlights as $highlight) {
$output->writeln(' - ' . $highlight);
}
}
$output->writeln('');
}
return Command::SUCCESS;
}
}