<?php
declare(strict_types=1);
namespace App\Controller;
use Ibexa\Contracts\ProductCatalog\Local\LocalProductServiceInterface;
use Ibexa\Contracts\ProductCatalog\ProductTypeServiceInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
final class TestController extends AbstractController
{
public function __construct(
private readonly LocalProductServiceInterface $productService,
private readonly ProductTypeServiceInterface $productTypeService,
) {}
#[Route('/test')]
public function test(): never
{
$productCreateStruct = $this->productService->newProductCreateStruct(
$this->productTypeService->getProductType('test_product'),
'eng-GB',
);
$productCreateStruct->setCode('test');
$productCreateStruct->setField(
'name',
'Test',
);
$productCreateStruct->setAttribute(
'test_attribute',
'test',
);
dd($this->productService->createProduct($productCreateStruct));
}
}