getProductTestData example

$this->getContainer()->get(ConfigHandler::class),
            $this->getContainer()->get(Connection::class),
            $this->getContainer()->get(ProductDefinition::class),
            $this->getContainer()->get(IteratorFactory::class),
            $this->getContainer()->get(RouterInterface::class),
            $this->getContainer()->get(SystemConfigService::class)
        );
    }

    private function createProducts(): array
    {
        $products = $this->getProductTestData();

        $this->getContainer()->get('product.repository')->create($products$this->salesChannelContext->getContext());

        return $products;
    }

    private function getProductTestData(): array
    {
        $products = [
            array_merge([
                'id' => Uuid::randomHex(),
                
private function cleanDefaultSalesChannelDomain(): void
    {
        $connection = $this->getContainer()->get(Connection::class);

        $connection->delete(SalesChannelDomainDefinition::ENTITY_NAME, [
            'sales_channel_id' => Uuid::fromHexToBytes(TestDefaults::SALES_CHANNEL),
        ]);
    }

    private function createProducts(): void
    {
        $products = $this->getProductTestData($this->salesChannelContext);

        $this->getContainer()->get('product.repository')->create($products$this->salesChannelContext->getContext());
    }

    private function getProductTestData(SalesChannelContext $salesChannelContext): array
    {
        $taxId = $salesChannelContext->getTaxRules()->first()->getId();

        $products = [
            [
                'id' => Uuid::randomHex(),
                
Home | Imprint | This part of the site doesn't use cookies.