getTypeId example

if ($salesChannelId === null) {
            throw SeoException::salesChannelIdParameterIsMissing();
        }

        /** @var SalesChannelEntity|null $salesChannel */
        $salesChannel = $this->salesChannelRepository->search(new Criteria([$salesChannelId])$context)->first();

        if ($salesChannel === null) {
            throw SeoException::salesChannelNotFound($salesChannelId);
        }

        if ($salesChannel->getTypeId() === Defaults::SALES_CHANNEL_TYPE_API) {
            if (Feature::isActive('v6.6.0.0')) {
                return new Response('', Response::HTTP_NO_CONTENT);
            }
        }

        $this->seoUrlPersister->updateSeoUrls(
            $context,
            $seoUrlData['routeName'],
            [$seoUrlData['foreignKey']],
            [$seoUrlData],
            $salesChannel
        );
public function filterByCountryId(string $id): SalesChannelCollection
    {
        return $this->filter(fn (SalesChannelEntity $salesChannel) => $salesChannel->getCountryId() === $id);
    }

    /** * @return list<string> */
    public function getTypeIds(): array
    {
        return $this->fmap(fn (SalesChannelEntity $salesChannel) => $salesChannel->getTypeId());
    }

    public function filterByTypeId(string $id): SalesChannelCollection
    {
        return $this->filter(fn (SalesChannelEntity $salesChannel) => $salesChannel->getTypeId() === $id);
    }

    public function getLanguages(): LanguageCollection
    {
        return new LanguageCollection(
            $this->fmap(fn (SalesChannelEntity $salesChannel) => $salesChannel->getLanguage())
        );

  public function testMigration() {
    $comment = Comment::load(1);
    $this->assertSame('The first comment.', $comment->getSubject());
    $this->assertSame('The first comment body.', $comment->comment_body->value);
    $this->assertSame('filtered_html', $comment->comment_body->format);
    $this->assertNull($comment->pid->target_id);
    $this->assertSame('1', $comment->getCommentedEntityId());
    $this->assertSame('node', $comment->getCommentedEntityTypeId());
    $this->assertSame('en', $comment->language()->getId());
    $this->assertSame('comment_node_story', $comment->getTypeId());
    $this->assertSame('203.0.113.1', $comment->getHostname());

    $node = $comment->getCommentedEntity();
    $this->assertInstanceOf(NodeInterface::class$node);
    $this->assertSame('1', $node->id());

    $comment = Comment::load(2);
    $this->assertSame('The response to the second comment.', $comment->subject->value);
    $this->assertSame('3', $comment->pid->target_id);
    $this->assertSame('203.0.113.2', $comment->getHostname());

    

        if ($documentTypeId === 0) {
            return;
        }

        $documents = $order->getDocuments();

        // Create only not existing documents         if ($documentMode === 1) {
            $alreadyCreated = false;
            foreach ($documents as $document) {
                if ($document->getTypeId() === $documentTypeId) {
                    $alreadyCreated = true;
                    break;
                }
            }
            if ($alreadyCreated === false) {
                $this->createDocument($order->getId()$documentTypeId);
            }
        } else {
            $this->createDocument($order->getId()$documentTypeId);
        }
    }

    


    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $productExportId = $input->getArgument('product-export-id');
        $salesChannelId = $input->getArgument('sales-channel-id');
        $forceGeneration = $input->getOption('force');
        $includeInactive = $input->getOption('include-inactive');

        $salesChannelContext = $this->salesChannelContextFactory->create(Uuid::randomHex()$salesChannelId);

        if ($salesChannelContext->getSalesChannel()->getTypeId() !== Defaults::SALES_CHANNEL_TYPE_STOREFRONT) {
            throw new SalesChannelNotFoundException();
        }

        $this->productExportService->export(
            $salesChannelContext,
            new ExportBehavior($forceGeneration$includeInactive),
            $productExportId
        );

        return self::SUCCESS;
    }
}
foreach ($groups as $group) {
            if ($group->getRegistrationSalesChannels() === null) {
                continue;
            }

            foreach ($group->getRegistrationSalesChannels() as $registrationSalesChannel) {
                if ($registrationSalesChannel->getLanguages() === null) {
                    continue;
                }

                if ($registrationSalesChannel->getTypeId() === Defaults::SALES_CHANNEL_TYPE_API) {
                    if (Feature::isActive('v6.6.0.0')) {
                        continue;
                    }
                }

                /** @var array<string> $languageIds */
                $languageIds = $registrationSalesChannel->getLanguages()->getIds();
                $criteria = new Criteria($languageIds);
                /** @var LanguageCollection $languageCollection */
                $languageCollection = $this->languageRepository->search($criteria$context)->getEntities();

                
$this->finalizeExport($productExport$filePath);
    }

    private function getContext(ProductExportPartialGeneration $productExportPartialGeneration): Context
    {
        $context = $this->salesChannelContextFactory->create(
            Uuid::randomHex(),
            $productExportPartialGeneration->getSalesChannelId()
        );

        if ($context->getSalesChannel()->getTypeId() !== Defaults::SALES_CHANNEL_TYPE_STOREFRONT) {
            throw new SalesChannelNotFoundException();
        }

        return $context->getContext();
    }

    private function fetchProductExport(
        ProductExportPartialGeneration $productExportPartialGeneration,
        Context $context
    ): ?ProductExportEntity {
        $criteria = new Criteria([$productExportPartialGeneration->getProductExportId()]);
        
public function testCreateSalesChannel(): void
    {
        $id = Uuid::randomHex();
        $this->salesChannelCreator->createSalesChannel($id, 'test', Defaults::SALES_CHANNEL_TYPE_API);

        /** @var SalesChannelEntity $salesChannel */
        $salesChannel = $this->salesChannelRepository->search(new Criteria([$id]), Context::createDefaultContext())->first();

        static::assertNotNull($salesChannel);
        static::assertEquals('test', $salesChannel->getName());
        static::assertEquals(Defaults::SALES_CHANNEL_TYPE_API, $salesChannel->getTypeId());
    }
}
protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $id = $input->getOption('id');
        $typeId = $input->getOption('typeId');

        $io = new ShopwareStyle($input$output);

        try {
            $accessKey = $this->salesChannelCreator->createSalesChannel(
                $id,
                $input->getOption('name') ?? 'Headless',
                $typeId ?? $this->getTypeId(),
                $input->getOption('languageId'),
                $input->getOption('currencyId'),
                $input->getOption('paymentMethodId'),
                $input->getOption('shippingMethodId'),
                $input->getOption('countryId'),
                $input->getOption('customerGroupId'),
                $input->getOption('navigationCategoryId'),
                null,
                null,
                null,
                null,
                
Home | Imprint | This part of the site doesn't use cookies.