$this->
View()->
loadTemplate('frontend/search/ajax.tpl'
);
/** @var SearchTermPreProcessorInterface $processor */
$processor =
$this->
get(\Shopware\Bundle\SearchBundle\SearchTermPreProcessorInterface::
class);
$term =
$processor->
process($this->
Request()->
getParam('sSearch'
));
if (!
$term || \
strlen($term) <
Shopware()->
Config()->
get('MinSearchLenght'
)) { return;
} $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);