How can we show in admin line items with parentId somehow in relation with parent products?

Hello everybody!

We’ve implemented a plugin that allows you to add same product to basket and add children(as individual products) to those ‚main‘ products. Everything looks ok in storefront, in order_line_item childrens are saved as separate line items which gets an ‚parentId‘. Our problem is that in admin area and also on documents generation, line items are shown totally random and we do not know which products are ‚seen‘ as childrens and which are main.

Does anyone knows how we can achieve a proper view based on the main/child relation based on parentId? Somehow a grouping by parentId…

Best regards,


Hello everyone !

For order documents I’ve found a solution and I’ll post it here maybe will help someone, but for admin order detail view I’m still struggle to get it work right.

Here’s the solution for order documents:

In services.xml:

In DocumentSubscriber.php


     * Handle document generation grouping parent/child line items
     * @param DocumentTemplateRendererParameterEvent $event
    public function onDocumentTemplateRendererParameterEvent(DocumentTemplateRendererParameterEvent $event): void
        //get event parameters
        $parameters = $event->getParameters();

        //get order
        $order = array_key_exists('order', $parameters) ? $parameters['order'] : null;

        if(!is_null($order)) {
            $aLineItems = [];
            $root = new OrderLineItemCollection();

            $orderLineItems = $order->getLineItems()->getElements();
            foreach ($order->getLineItems()->getElements() as $lineItemId => $lineItemEntity){
                if(array_key_exists($lineItemEntity->getParentId(), $orderLineItems)) {
                    $aLineItems[$lineItemEntity->getParentId()][] = $lineItemEntity->getId();
                } else {
                    $aLineItems[$lineItemEntity->getId()][] = $lineItemEntity->getId();


            foreach($aLineItems as $lineItemId => $childIds){
                foreach($childIds as $childId){





Best regards,


Hello everyone!

I’m trying to get this view work also in admin vue js based on the logic for order documents but I’m getting stuck to vue js code.

I’ve tried to change the order line items in '…\shopware\administration\Resources\app\administration\src\module\sw-order\component\sw-order-line-items-grid\index.js


data() {
        return {
            isLoading: false,
            selectedItems: {},
            newOrderedLineItems: [[]]
computed: {
        orderLineItems() {
            this.order.lineItems.forEach((orderLineItem) => {
                if(this.inArray(orderLineItem.parentId, this.order.lineItems.getIds())) {
                    this.newOrderedLineItems[orderLineItem.parentId] = [];
                } else {
                    this.newOrderedLineItems[] = [];

            return this.order.lineItems;

The multidimensional array gets populated but only with the last element for childs.

I do not have too much experience with vue js and any help will be apreaciatted.

Best regards,


Hi Sorin,

I need to group children Products too.
Can you please share your code.
Services.xml and subscriber or …


Thanks for the information. I’ll be sure to keep an eye on this thread. looking for the same issue.