updateAvailableFlag example

$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) {
                $query->execute(['id' => Uuid::fromHexToBytes((string) $id), 'quantity' => $quantity]);
            }
        });

        Profiler::trace('order::update-flag', function D) use ($ids$event): void {
            $this->updateAvailableFlag(\array_keys($ids)$event->getContext());
        });
    }

    /** * If the product of an order item changed, the stocks of the old product and the new product must be updated. */
    public function lineItemWritten(EntityWrittenEvent $event): void
    {
        if ($this->isDisabled()) {
            return;
        }

        
$this->connection->prepare($sql)
        );

        foreach ($changes as $alteration) {
            $query->execute([
                'quantity' => $alteration->quantityDelta(),
                'id' => Uuid::fromHexToBytes($alteration->productId),
                'version' => Uuid::fromHexToBytes(Defaults::LIVE_VERSION),
            ]);
        }

        $this->updateAvailableFlag(array_column($changes, 'productId')$context);
    }

    /** * @param list<string> $productIds */
    public function index(array $productIds, Context $context): void
    {
        if ($context->getVersionId() !== Defaults::LIVE_VERSION) {
            return;
        }

        
Home | Imprint | This part of the site doesn't use cookies.