$repository =
$this->
getRepository($config);
$criteria =
new Criteria();
if ($previewCriteria !== null
) { $criteria =
$previewCriteria;
} $criteria->
setLimit(10
);
$ids =
$repository->
searchIds($criteria,
$context)->
getIds();
if (empty($ids)) { throw SeoException::
noEntitiesForPreview($repository->
getDefinition()->
getEntityName(),
$seoUrlTemplate['routeName'
]);
} $salesChannelId =
$seoUrlTemplate['salesChannelId'
] ?? null;
$template =
$seoUrlTemplate['template'
] ?? '';
if (\
is_string($salesChannelId)) { /** @var SalesChannelEntity|null $salesChannel */
$salesChannel =
$this->salesChannelRepository->
search((new Criteria([$salesChannelId]))->
setLimit(1
),
$context)->
get($salesChannelId);
if ($salesChannel === null
) { throw SeoException::
invalidSalesChannelId($salesChannelId);
}