# Add Custom ID to Lineitem If LineItem is a Variation (option group) of a Parent Lineitem

**URL:** <https://forum.shopware.com/t/add-custom-id-to-lineitem-if-lineitem-is-a-variation-option-group-of-a-parent-lineitem/88727>\
**Category:** Shopware 6 (German)\
**Tags:** general, programming, templates--design, other, themes--design, plugin-wünsche\
**Created:** [1. Juli 2021 um 08:09 UTC](https://forum.shopware.com/t/add-custom-id-to-lineitem-if-lineitem-is-a-variation-option-group-of-a-parent-lineitem/88727 "2021-07-01T08:09:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![arash.yazdani59](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/arash.yazdani59/32/13954_2.png) [@arash.yazdani59](https://forum.shopware.com/u/arash.yazdani59)\
**Post date:** [1. Juli 2021 um 08:09 UTC](https://forum.shopware.com/t/add-custom-id-to-lineitem-if-lineitem-is-a-variation-option-group-of-a-parent-lineitem/88727/1 "2021-07-01T08:09:34Z")

</div>

Hi,

I need to add a Custom Id to LineItem(s) that are variations (color, size) of a Parent Line item.  
Since Now i tryed this:

```auto
use Shopware\Core\Checkout\Cart\Event\BeforeLineItemAddedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class AddDataToPage implements EventSubscriberInterface
{   
   
    public static function getSubscribedEvents()
    {
        return [BeforeLineItemAddedEvent::class => 'onLineItemAdded'];
    }

    /**
     * @param onLineItemAdded $event
     * @throws \Shopware\Core\Checkout\Cart\Exception\InvalidPayloadException
     */
    public function onLineItemAdded(BeforeLineItemAddedEvent $event)
    {
       
        $lineitems = $event->getLineItem();
        $event->isMerged() == true;
        $payloaditem = $lineitems->getPayload();
        
        // I'm stuck here i want to do this: if lineitem is a variation add customfield to lineitem with variation and his parent
        if($lineitems->getReferencedId() == "df50709c534e499488c6fe02312ca526"){
            $lineitems->setPayloadValue("myChilds", true);
        }
        else{
            $lineitems->setPayloadValue("myChilds", false);
        }
    }
    
}

```

Unfortunately there is nothing Common between Line Item(s) with variations.  
Does anyone have an Idea?
