How to group Products with variation under parent product on Storefront

Hi,
I’m trying to build this page :
Unbenannt
But i have no idea how to do that, because LineItems with variation are seperated and they not children.
in Twig i have tried but since LineItems are seperated and there is no id or somthnig i couldn’t do that.
i tried to add Enitity to LineItems using :

but it seems documents are not correct.
please if anyone had an idea or somthnig please share your code with details
Thank you.

Custom Products does something similar. With the next version the documents should support nested line items. So if you try out the current development version, it might work.

unfortunately i can’t use Custom Products because we have a lots of Products that already are placed in the Website.
I’m trying to do this: 1. if products have a variation and first seven productNumber are the same add a customfield to payload 2. in twig file use that customfield and using for loops and other twig functions to create my custom page

so far i tryed to create a Service :


use Shopware\Core\Checkout\Cart\Event\CartChangedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;


class AddDataToPage implements EventSubscriberInterface
{

    public static function getSubscribedEvents()
    {
        return [CartChangedEvent::class => 'onLineItemAdded'];
    }

    /**
     * @param onLineItemAdded $event
     * @throws \Shopware\Core\Checkout\Cart\Exception\InvalidPayloadException
     */
    public function onLineItemAdded(CartChangedEvent $event)
    {
        $myCart = $event->getCart();
        $myLineItems = $myCart->getLineItems();
        $mypayload = $myLineItems->getPayload();
        
       
        foreach ($myLineItems as $lineitem) {
                $lineitem->setPayloadValue("test", array(["aaah"]));
                var_dump($lineitem);

        } 
    }
}

there is a problem here that i don’t understand.
when i use var_dump($lineitem); i see my $lineitem->setPayloadValue(„test“, array([„aaah“])); but in twig when i use dump i don’t see test in payload array.
any idea why?