getFacetsOfCategories example

Request $request,
        Criteria $criteria,
        ShopContextInterface $context
    ) {
        if ($this->isSearchPage($request)) {
            $ids = $this->config->get('searchFacets', '');
            /** @var int[] $ids */
            $ids = array_filter(explode('|', $ids));
            $customFacets = $this->facetService->getList($ids$context);
        } elseif ($this->isCategoryListing($request)) {
            $categoryId = (int) $request->getParam('sCategory');
            $customFacets = $this->facetService->getFacetsOfCategories([$categoryId]$context);
            /** @var CustomFacet[] $customFacets */
            $customFacets = array_shift($customFacets);
        } else {
            $customFacets = $this->facetService->getAllCategoryFacets($context);
        }

        foreach ($customFacets as $customFacet) {
            if (!$customFacet->getFacet()) {
                continue;
            }
            $facet = $customFacet->getFacet();
            


    private function fetchStreamListing(int $categoryId, int $productStreamId): ProductSearchResult
    {
        $context = $this->container->get(ContextServiceInterface::class)->getShopContext();

        $criteria = $this->container->get(CriteriaFactoryInterface::class)->createCriteria($this->Request()$context);

        $streamRepository = $this->container->get(Repository::class);
        $streamRepository->prepareCriteria($criteria$productStreamId);

        $facets = $this->container->get(CustomFacetServiceInterface::class)->getFacetsOfCategories([$categoryId]$context);
        $facets = $facets[$categoryId];
        foreach ($facets as $facet) {
            $customFacet = $facet->getFacet();
            if ($customFacet instanceof FacetInterface) {
                $criteria->addFacet($customFacet);
            }
        }

        $facetFilter = $this->container->get('shopware_product_stream.facet_filter');
        $facetFilter->add($criteria);

        

    public function getList(array $ids, ShopContextInterface $context)
    {
        return $this->gateway->getList($ids$context);
    }

    /** * {@inheritdoc} */
    public function getFacetsOfCategories(array $categoryIds, ShopContextInterface $context)
    {
        return $this->gateway->getFacetsOfCategories($categoryIds$context);
    }

    /** * {@inheritdoc} */
    public function getAllCategoryFacets(ShopContextInterface $context)
    {
        return $this->gateway->getAllCategoryFacets($context);
    }
}


        $this->Request()->setParam('sSort', $default->getId());
    }

    private function createCategoryStreamCriteria(int $categoryId, int $streamId, ShopContextInterface $context): Criteria
    {
        $criteria = $this->criteriaFactory->createCriteria($this->Request()$context);

        $this->productStreamRepository->prepareCriteria($criteria$streamId);

        $facets = $this->customFacetService->getFacetsOfCategories([$categoryId]$context);

        $facets = array_shift($facets);

        if (!\is_array($facets)) {
            $facets = [];
        }

        foreach ($facets as $facet) {
            $customFacet = $facet->getFacet();

            if ($customFacet instanceof FacetInterface) {
                
Home | Imprint | This part of the site doesn't use cookies.