getStreamId example

return array_unique(array_filter($event->getTags()));
    }

    /** * @return array<string> */
    private function extractStreamTags(ProductCrossSellingRouteResponse $response): array
    {
        $ids = [];

        foreach ($response->getResult() as $element) {
            $ids[] = $element->getStreamId();
        }

        $ids = array_unique(array_filter($ids));

        return array_map(EntityCacheKeyGenerator::buildStreamTag(...)$ids);
    }

    /** * @return array<string> */
    private function extractProductIds(ProductCrossSellingRouteResponse $response): array
    {
$streamIds = [];

        $slots = $page->getElementsOfType('product-slider');
        /** @var CmsSlotEntity $slot */
        foreach ($slots as $slot) {
            $slider = $slot->getData();

            if (!$slider instanceof ProductSliderStruct) {
                continue;
            }

            if ($slider->getStreamId() !== null) {
                $streamIds[] = $slider->getStreamId();
            }

            if ($slider->getProducts() === null) {
                continue;
            }
            foreach ($slider->getProducts() as $product) {
                $ids[] = $product->getId();
                $ids[] = $product->getParentId();
            }
        }

        
$streamIds = [];

        $slots = $page->getElementsOfType('product-slider');
        /** @var CmsSlotEntity $slot */
        foreach ($slots as $slot) {
            $slider = $slot->getData();

            if (!$slider instanceof ProductSliderStruct) {
                continue;
            }

            if ($slider->getStreamId() !== null) {
                $streamIds[] = $slider->getStreamId();
            }

            if ($slider->getProducts() === null) {
                continue;
            }
            foreach ($slider->getProducts() as $product) {
                $ids[] = $product->getId();
                $ids[] = $product->getParentId();
            }
        }

        
$this->createMock(SalesChannelContext::class),
            $criteria
        )->getResult();

        static::assertSame([
            'product.visibilities.visibility',
            'product.visibilities.salesChannelId',
            'product.active',
            'product.product_stream',
        ]$criteria->getFilterFields());

        static::assertSame($streamId$result->getStreamId());
    }

    public function testClassIsBaseOfDecorationChain(): void
    {
        $controller = new ProductListingRoute(
            $this->createMock(ProductListingLoader::class),
            $this->createMock(EntityRepository::class),
            $this->createMock(ProductStreamBuilderInterface::class),
        );

        $this->expectException(DecorationPatternException::class);

        
return null;
        }

        return self::buildName($categoryId) . '-' . md5(Json::encode($event->getParts()));
    }

    /** * @return array<string> */
    private function generateTags(string $categoryId, Request $request, ProductListingRouteResponse $response, SalesChannelContext $context, Criteria $criteria): array
    {
        $streamId = $response->getResult()->getStreamId();

        $tags = array_merge(
            $this->tracer->get(self::buildName($categoryId)),
            [$streamId ? EntityCacheKeyGenerator::buildStreamTag($streamId) : null],
            [self::buildName($categoryId)]
        );

        $event = new ProductListingRouteCacheTagsEvent($tags$categoryId$request$response$context$criteria);
        $this->dispatcher->dispatch($event);

        return array_unique(array_filter($event->getTags()));
    }


    private function addCondition(AssignedToStreamCondition $condition, QueryBuilder $query): void
    {
        $query->innerJoin(
            'customer',
            's_customer_streams_mapping',
            'mapping',
            'mapping.customer_id = customer.id AND mapping.stream_id = :streamId'
        );

        $query->setParameter(':streamId', $condition->getStreamId());
    }
}
Home | Imprint | This part of the site doesn't use cookies.