# Extended entity upsert() fügt Datensätze an anstatt update

**URL:** <https://forum.shopware.com/t/extended-entity-upsert-fuegt-datensaetze-an-anstatt-update/94837>\
**Category:** Administration\
**Tags:** administration, programming\
**Created:** [15. Juni 2022 um 08:52 UTC](https://forum.shopware.com/t/extended-entity-upsert-fuegt-datensaetze-an-anstatt-update/94837 "2022-06-15T08:52:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rammi22](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rammi22](https://forum.shopware.com/u/rammi22)\
**Post date:** [15. Juni 2022 um 08:52 UTC](https://forum.shopware.com/t/extended-entity-upsert-fuegt-datensaetze-an-anstatt-update/94837/1 "2022-06-15T08:52:50Z")

</div>

Hallo,

ich habe das [`ProductEntity` um ein Feld erweitert](https://developer.shopware.com/docs/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities#writing-into-the-new-field).

Bei Ausführung von `upsert()` wird:

- `product` wird überschrieben
- in der Erweiterung wird ein **neuer Datensatz angefügt**.

Ich erwarte lt Anleitung, das bei `upsert()` / `update()` der Datensatz der Erweiterung stattdessen **überschrieben** wird.

```auto
...
$this->productRepository->upsert([[
                'id' => $idMainProduct,
                'components' => [
                    'components' => $components->getComponents()
                ]
            ]], $context);

```

Gibt es da eine Konfiguration?

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [15. Juni 2022 um 10:03 UTC](https://forum.shopware.com/t/extended-entity-upsert-fuegt-datensaetze-an-anstatt-update/94837/2 "2022-06-15T10:03:49Z")

</div>

Ohne es getestet zu haben, musst du vermutlich für jede Assoziation/Extension die UUID mit angeben, damit diese aktualisiert und nicht neu angelegt wird.

```auto
[
                'id' => $idMainProduct,
                'components' => [
                    'id' => xyz,
                    'components' => $components->getComponents()
                ]

```

---

<div class="post-metadata">

**Author:** ![rammi22](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rammi22](https://forum.shopware.com/u/rammi22)\
**Post date:** [16. Juni 2022 um 05:11 UTC](https://forum.shopware.com/t/extended-entity-upsert-fuegt-datensaetze-an-anstatt-update/94837/3 "2022-06-16T05:11:26Z")

</div>

@Max_Shop Danke, das war die Lösung

**EDIT**  
Vue/Js

> [@How to create and save a new field in admin module in shopware 6?](https://forum.shopware.com/t/how-to-create-and-save-a-new-field-in-admin-module-in-shopware-6/72110/7):
>
> You can simply write your data into this.product.extensions.your-extension Shopware will automatically write it to the database when you save the product (Autoloading might need to be active for this to work I’m not sure). This worked for me: methods: { // This is the @change Method on my Input updateData(){ this.myExtension.option = this.selectedOption; this.product.extensions.myExtension = this.myExtension; } }, created(){ if(!this.product.extensions.myExtens…
