convertProducts example

$this->setDefaultSorting();

        /** @var ShopContextInterface $context */
        $context = $this->get(\Shopware\Bundle\StoreFrontBundle\Service\ContextServiceInterface::class)->getShopContext();

        $criteria = $this->get(\Shopware\Bundle\SearchBundle\StoreFrontCriteriaFactoryInterface::class)
            ->createAjaxSearchCriteria($this->Request()$context);

        $result = $this->search($term$criteria$context);

        if ($result->getTotalCount() > 0) {
            $products = $this->convertProducts($result);
            $this->View()->assign('searchResult', $result);
            $this->View()->assign('sSearchRequest', ['sSearch' => $term]);
            $this->View()->assign('sSearchResults', [
                'sResults' => $products,
                'sArticlesCount' => $result->getTotalCount(),
            ]);
        }
    }

    /** * @return array */
$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()
            );
        }

        $pageCounts = $this->get(Shopware_Components_Config::class)->get('fuzzySearchSelectPerPage');

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