# Override OrderLineItem label after a customer ordered

**URL:** <https://forum.shopware.com/t/override-orderlineitem-label-after-a-customer-ordered/89146>\
**Category:** Programming (EN)\
**Tags:** programming\
**Created:** [14. Juli 2021 um 12:09 UTC](https://forum.shopware.com/t/override-orderlineitem-label-after-a-customer-ordered/89146 "2021-07-14T12:09:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rafu](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rafu](https://forum.shopware.com/u/rafu)\
**Post date:** [14. Juli 2021 um 12:09 UTC](https://forum.shopware.com/t/override-orderlineitem-label-after-a-customer-ordered/89146/1 "2021-07-14T12:09:14Z")

</div>

Hi there,

I’m trying to override the label or description of an order line item, after a customer placed an order. To do so, I tried to listen to the `order.written`-event. The event handling looks like this (simplified):

```auto
// This is the event-handler
public function onOrderWritten(EntityWrittenEvent $event)
{
    foreach ($event->getWriteResults() as $result) {
        $orderId = $result->getPrimaryKey();

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('orderId', $orderId));

        $data = $this->orderLineItemRepository->search($criteria, $context);

        $updates = [];
        foreach ($data->getEntities() as $lineItem) {
            $updates[] = [
                'id' => $lineItem->getId(),
                'label' => $lineItem->getLabel() . ' <some more info>',
            ];
        }

        if (!empty($updates)) {
            $this->orderLineItemRepository->update($updates, $context);
        }
    }
}

```

This runs into an endless loop, I think, this might be, because the `order.written`-event is called everytime, I update the line item. So it triggers a recursion… Is there another way on how to override the line items?

And, for general understanding: Is there anything like an EntityManager, like the one from Symfony/Doctrine? Or do I always have to look for the correct keys in the entity-table inside the db, to update values on an entity?

Thanks in advance 🙂
