$criteria->
addSorting( new FieldSorting('wishlists.createdAt', FieldSorting::DESCENDING
) );
$criteria =
$this->
handleAvailableStock($criteria,
$context);
$event =
new CustomerWishlistLoaderCriteriaEvent($criteria,
$context);
$this->eventDispatcher->
dispatch($event);
$products =
$this->productRepository->
search($criteria,
$context);
$event =
new CustomerWishlistProductListingResultEvent($request,
$products,
$context);
$this->eventDispatcher->
dispatch($event);
return $products;
} private function handleAvailableStock(Criteria
$criteria, SalesChannelContext
$context): Criteria
{ $hide =
$this->systemConfigService->
getBool( 'core.listing.hideCloseoutProductsWhenOutOfStock',
$context->
getSalesChannelId() );