getNestedLineItems example

$result = $this->orderRoute
            ->load($event->getStoreApiRequest()$salesChannelContext$criteria);

        $order = $result->getOrders()->first();

        if (!$order instanceof OrderEntity) {
            throw new NotFoundHttpException();
        }

        $page = AccountOrderDetailPage::createFrom($this->genericLoader->load($request$salesChannelContext));
        $page->setLineItems($order->getNestedLineItems());
        $page->setOrder($order);

        if ($page->getMetaInformation()) {
            $page->getMetaInformation()->setRobots('noindex,follow');
        }

        $this->eventDispatcher->dispatch(
            new AccountOrderDetailPageLoadedEvent($page$salesChannelContext$request)
        );

        return $page;
    }
->addAssociation('lineItems')
            ->addAssociation('transactions')
            ->addAssociation('deliveries.shippingMethod')
            ->addAssociation('deliveries.positions.orderLineItem')
            ->addAssociation('deliveries.shippingOrderAddress.country')
            ->addAssociation('deliveries.shippingOrderAddress.countryState');

        /** @var OrderEntity $order */
        $order = $this->getContainer()->get('order.repository')
            ->search($criteria$this->context)
            ->get($orderId);
        static::assertNotNull($order->getNestedLineItems());

        // check lineItem sorting         $idx = 0;
        foreach ($order->getNestedLineItems() as $lineItem) {
            if ($idx === 0) {
                static::assertEquals($parentProductId$lineItem->getReferencedId());
            } else {
                static::assertEquals($rootProductId$lineItem->getReferencedId());
            }
            ++$idx;
        }

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