if (!
$referencedId) { continue;
} if (!\
array_key_exists($referencedId,
$ids)) { $ids[$referencedId] = 0;
} $ids[$referencedId] +=
$lineItem->
getQuantity();
} $filteredIds =
$this->stockUpdateFilter->
filterProductIdsForStockUpdates(\
array_keys($ids),
$event->
getContext());
$ids = \
array_filter($ids,
static fn (string
$id) => \
in_array($id,
$filteredIds, true
), \ARRAY_FILTER_USE_KEY
);
// order placed event is a high load event. Because of the high load, we simply reduce the quantity here instead of executing the high costs `update` function
$query =
new RetryableQuery( $this->connection,
$this->connection->
prepare('UPDATE product SET available_stock = available_stock - :quantity WHERE id = :id'
) );
Profiler::
trace('order::update-stock',
static function D
) use ($query,
$ids): void
{ foreach ($ids as $id =>
$quantity) {