$result = null;
// If the search for product numbers is active, do that first
if ((int) $this->
get(\Shopware_Components_Config::
class)->
get('activateNumberSearch'
) === 1
) { // Check if search-term is a valid product-number
/** @var ListProduct|null $directHit */
$directHit =
$this->
get(\Shopware\Bundle\StoreFrontBundle\Service\ListProductServiceInterface::
class) ->
get($term,
$context);
if ($directHit) { /** @var ProductSearchResult $result */
$result =
new ProductSearchResult([$directHit], 1,
[],
$criteria,
$context);
} } // If number search is inactive or didn't find anything, do a regular search
if (!
$result ||
$result->
getTotalCount() === 0
) { $result =
$this->
get(\Shopware\Bundle\SearchBundle\ProductSearchInterface::
class)->
search($criteria,
$context);
} return $result;
}}