$categoryCriteria =
new Criteria([$categoryId]);
$categoryCriteria->
setTitle('product-listing-route::category-loading'
);
$categoryCriteria->
addFields(['productAssignmentType', 'productStreamId'
]);
$categoryCriteria->
setLimit(1
);
/** @var PartialEntity|null $category */
$category =
$this->categoryRepository->
search($categoryCriteria,
$context->
getContext())->
first();
if (!
$category) { throw ProductException::
categoryNotFound($categoryId);
} $this->
extendCriteria($context,
$criteria,
$category);
$entities =
$this->listingLoader->
load($criteria,
$context);
$result = ProductListingResult::
createFrom($entities);
$result->
addState(...
$entities->
getStates());
$result->
setStreamId($category->
get('productStreamId'
));
return new ProductListingRouteResponse($result);
}