setStreamIds example



    /** * @param array<string> $streamIds * @param array<string>|null $categoryIds */
    private function getProductEntity(?array $streamIds, ?array $categoryIds): ProductEntity
    {
        $product = new ProductEntity();

        $product->setId(Uuid::randomHex());
        $product->setStreamIds($streamIds);
        $product->setCategoryIds($categoryIds);

        return $product;
    }

    private function getSalesChannelContext(): SalesChannelContext
    {
        $salesChannelEntity = new SalesChannelEntity();
        $salesChannelEntity->setId('salesChannelId');
        $salesChannelEntity->setNavigationCategoryId('navigationCategoryId');
        $salesChannelEntity->setServiceCategoryId('serviceCategoryId');
        
$this->createTestProduct($productData);

        $criteria = new Criteria([$this->ids->get('seo-product')]);
        $criteria->addAssociation('categories');

        /** @var ProductEntity $product */
        $product = $this->productRepository->search($criteria, Context::createDefaultContext())->first();

        $this->createProductStreams();
        $this->createCategoryStreams();
        $product->setStreamIds([$this->ids->create('stream_id_1')]);

        $category = $this->breadcrumbBuilder->getProductSeoCategory($product$this->salesChannelContext);
        $category2 = $this->breadcrumbBuilder->getProductSeoCategory($product$this->contextFactory->create('', $this->ids->get('sales-channel-2')));

        static::assertInstanceOf(CategoryCollection::class$product->getCategories());

        if ($hasCategories) {
            static::assertInstanceOf(CategoryEntity::class$category);
            static::assertInstanceOf(CategoryEntity::class$category2);
            static::assertNotCount(0, $product->getCategories());

            
Home | Imprint | This part of the site doesn't use cookies.