$aggregations = null;
if ($criteria->
getAggregations()) { $aggregations =
$this->
aggregate($criteria,
$salesChannelContext);
} if (!RepositorySearchDetector::
isSearchRequired($this->definition,
$criteria)) { $entities =
$this->
read($criteria,
$salesChannelContext);
return new EntitySearchResult($this->definition->
getEntityName(),
$entities->
count(),
$entities,
$aggregations,
$criteria,
$salesChannelContext->
getContext());
} $ids =
$this->
doSearch($criteria,
$salesChannelContext);
if (empty($ids->
getIds())) { /** @var TEntityCollection $collection */
$collection =
$this->definition->
getCollectionClass();
return new EntitySearchResult($this->definition->
getEntityName(),
$ids->
getTotal(),
new $collection(),
$aggregations,
$criteria,
$salesChannelContext->
getContext());
} $readCriteria =
$criteria->
cloneForRead($ids->
getIds());
$entities =
$this->
read($readCriteria,
$salesChannelContext);