addFilters example



        foreach ($filters as $filter) {
            $excluded = $filters->filtered();

            if ($filter->exclude()) {
                $excluded = $excluded->blacklist($filter->getName());
            }

            foreach ($filter->getAggregations() as $aggregation) {
                if ($aggregation instanceof FilterAggregation) {
                    $aggregation->addFilters($excluded->getFilters());

                    $aggregations[] = $aggregation;

                    continue;
                }

                $aggregation = new FilterAggregation(
                    $aggregation->getName(),
                    $aggregation,
                    $excluded->getFilters()
                );

                
$routes = $reader->read(
                $class,
                $this->defaultController,
                $this->defaultMethod
            );

            if ($routes === []) {
                continue;
            }

            $routes = $this->addFilters($routes);

            foreach ($routes as $item) {
                $route = $item['route'] . $item['route_params'];

                // For module routing                 if ($this->prefix !== '' && $route === '/') {
                    $route = $this->prefix;
                } elseif ($this->prefix !== '') {
                    $route = $this->prefix . '/' . $route;
                }

                
$search->setFrom($criteria->offset);
        }
        if ($criteria->limit) {
            $search->setSize($criteria->limit);
        }

        if ($criteria->term) {
            $search->addQuery($this->buildSearchQuery($criteria));
        }

        if (!empty($criteria->conditions)) {
            $this->addFilters($search$criteria);
        }
        if (!empty($criteria->sortings)) {
            $this->addSortings($criteria$search);
        }

        return $search;
    }

    protected function fetch(Search $search)
    {
        $arguments = [
            


        $result = $this->hydrator->hydrate($definition$criteria$context$result);
        $result->addState(self::RESULT_STATE);

        return $result;
    }

    private function createSearch(EntityDefinition $definition, Criteria $criteria, Context $context): Search
    {
        $search = new Search();
        $this->helper->addFilters($definition$criteria$search$context);
        $this->helper->addQueries($definition$criteria$search$context);
        $this->helper->addAggregations($definition$criteria$search$context);
        $this->helper->addTerm($criteria$search$context$definition);
        $this->helper->handleIds($definition$criteria$search$context);
        $search->setSize(0);

        return $search;
    }
}
throw new DecorationPatternException(self::class);
    }

    #[Route(path: '/store-api/product/{productId}', name: 'store-api.product.detail', methods: ['POST'], defaults: ['_entity' => 'product'])]     public function load(string $productId, Request $request, SalesChannelContext $context, Criteria $criteria): ProductDetailRouteResponse
    {
        return Profiler::trace('product-detail-route', function D) use ($productId$request$context$criteria) {
            $mainVariantId = $this->checkVariantListingConfig($productId$context);

            $productId = $mainVariantId ?? $this->findBestVariant($productId$context);

            $this->addFilters($context$criteria);

            $criteria->setIds([$productId]);
            $criteria->setTitle('product-detail-route');

            $product = $this->productRepository
                ->search($criteria$context)
                ->first();

            if (!($product instanceof SalesChannelProductEntity)) {
                throw new ProductNotFoundException($productId);
            }

            
$result->addState(self::RESULT_STATE);

        return $result;
    }

    private function createSearch(Criteria $criteria, EntityDefinition $definition, Context $context): Search
    {
        $search = new Search();

        $this->helper->handleIds($definition$criteria$search$context);
        $this->helper->addFilters($definition$criteria$search$context);
        $this->helper->addPostFilters($definition$criteria$search$context);
        $this->helper->addQueries($definition$criteria$search$context);
        $this->helper->addSortings($definition$criteria$search$context);
        $this->helper->addTerm($criteria$search$context$definition);

        $search->setSize(self::MAX_LIMIT);
        $limit = $criteria->getLimit();
        if ($limit !== null) {
            $search->setSize($limit);
        }
        $search->setFrom((int) $criteria->getOffset());

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