createSearchCriteria example

if (!$this->Request()->getParam('loadProducts')) {
            $criteria->limit(1);
        }

        return $search->search($criteria$context);
    }

    private function fetchSearchListing(): ProductSearchResult
    {
        $context = $this->container->get(ContextServiceInterface::class)->getShopContext();

        $criteria = $this->container->get(StoreFrontCriteriaFactoryInterface::class)->createSearchCriteria($this->Request()$context);

        $criteria->setGeneratePartialFacets(
            $this->container->get(Shopware_Components_Config::class)->get('listingMode') === 'filter_ajax_reload'
        );

        if (!$this->Request()->get('loadFacets')) {
            $criteria->resetFacets();
        }

        $search = $this->container->get(ProductSearchInterface::class);

        
$this->View()->loadTemplate('frontend/search/fuzzy.tpl');

        $minLengthSearchTerm = $this->get(Shopware_Components_Config::class)->get('minSearchLenght');
        if (\strlen($term) < (int) $minLengthSearchTerm) {
            return;
        }

        $context = $this->get(ContextServiceInterface::class)->getShopContext();

        $criteria = Shopware()->Container()->get(StoreFrontCriteriaFactoryInterface::class)
            ->createSearchCriteria($this->Request()$context);

        $result = $this->get(ProductSearchInterface::class)->search($criteria$context);
        $products = $this->convertProducts($result);

        if ($this->get(Shopware_Components_Config::class)->get('traceSearch', true)) {
            $this->get('shopware_searchdbal.search_term_logger')->logResult(
                $criteria,
                $result,
                $context->getShop()
            );
        }

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