public function salesChannelLoaded(SalesChannelEntityLoadedEvent
$event): void
{ $stocks =
$this->stockStorage->
load( new StockLoadRequest($event->
getIds()),
$event->
getSalesChannelContext() );
foreach ($event->
getEntities() as $product) { /** @var ProductEntity $product */
$stock =
$stocks->
getStockForProductId($product->
getId());
if ($stock === null
) { continue;
} $product->
assign([ // required stock data
'stock' =>
$stock->stock,
'available' =>
$stock->available,
// optional stock data
'minPurchase' =>
$stock->minPurchase ??
$product->
get('minPurchase'
),