getProductsOfOrder example

->setParameter('voucherId', $voucherId)
            ->setMaxResults(1)
            ->getQuery()
            ->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY);
    }

    /** * @return ProductVariant[] */
    private function getOutOfStockProducts(Order $order): array
    {
        $products = $this->getProductsOfOrder($order);

        $invalid = [];
        foreach ($products as $product) {
            $position = $this->getOrderPositionByProduct($product$order);

            if (!$position) {
                continue;
            }

            $newStock = $product->getInStock() - $position->getQuantity();

            


        if ($event->getContext()->getVersionId() !== Defaults::LIVE_VERSION) {
            return;
        }

        if ($event->getEntityName() !== 'order') {
            return;
        }

        if ($event->getToPlace()->getTechnicalName() === OrderStates::STATE_COMPLETED) {
            $products = $this->getProductsOfOrder($event->getEntityId()$event->getContext());

            $this->updateStockAndSales($products, -1);

            return;
        }

        if ($event->getFromPlace()->getTechnicalName() === OrderStates::STATE_COMPLETED) {
            $products = $this->getProductsOfOrder($event->getEntityId()$event->getContext());

            $this->updateStockAndSales($products, +1);

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