#[Route(path: '/store-api/product-listing/{categoryId}', name: 'store-api.product.listing', methods: ['POST'], defaults: ['_entity' => 'product'])]
public function load(string
$categoryId, Request
$request, SalesChannelContext
$context, Criteria
$criteria): ProductListingRouteResponse
{ $criteria->
addFilter( new ProductAvailableFilter($context->
getSalesChannel()->
getId(), ProductVisibilityDefinition::VISIBILITY_ALL
) );
$criteria->
setTitle('product-listing-route::loading'
);
$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);