# \[REST-API\] Varianten Update fügt nicht hinzu sondern ersetzt

**URL:** https://forum.shopware.com/t/rest-api-varianten-update-fugt-nicht-hinzu-sondern-ersetzt/57014
**Category:** Programmierung
**Created:** [11. Dezember 2018 um 22:36 UTC](https://forum.shopware.com/t/rest-api-varianten-update-fugt-nicht-hinzu-sondern-ersetzt/57014 "2018-12-11T22:36:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Magnum](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Magnum](https://forum.shopware.com/u/Magnum)
#### Post date: [11. Dezember 2018 um 22:36 UTC](https://forum.shopware.com/t/rest-api-varianten-update-fugt-nicht-hinzu-sondern-ersetzt/57014/1 "2018-12-11T22:36:12Z")

</div>

Hallo zusammen,

Ich beschäftige mich gerade mit der Rest-API und dem Update von Varianten. Soweit funktioniert alles einwandfrei, doch wenn ich versuche zu den bestehenden Varianten eine weitere hinzuzufügen werden alle Varianten im Backend richtig angezeigt, doch im Frontend kann ich nur die&nbsp;letzte importierte&nbsp;Variante auswählen. Ich habe bereits einige Versuche hinter mir, doch ich komme auf keinen nenner.

An für sich weiß ich wo der Fehler liegt. In der Tabelle&nbsp; **s\_article\_configurator\_options&nbsp;** erhält jede&nbsp;Variante jeweils die Position 0. Importiere ich mehrere Datensätze bekommt jeder eine fortlaufende Positionsnummer. Das hält aber nur bis zum nächsten import.&nbsp;

Nun dachte ich mir, ich füge den Wert **position&nbsp;** ein und erhöhe jeweils den Wert. Dies hatte aber leider nicht das erhoffte Ergebnis.

```
 Erster Import:

 $updateArticle = array( 'configuratorSet' =\> array( 'groups' =\> array( array( 'name' =\> 'Typ', 'options' =\> array( array('name' =\> 'SAAB10006'), ) ), array( 'name' =\> 'Serie', 'options' =\> array( array('name' =\> '200003'), ) ), ) ), 'taxId' =\> 1, 'variants' =\> array( array( 'isMain' =\> true, 'active' =\> true, 'number' =\> 'SW10020', 'inStock' =\> 1, 'position' =\> 0, 'additionaltext' =\> '', 'configuratorOptions' =\> array( array('group' =\> 'Typ', 'option' =\> '200003'), array('group' =\> 'Serie', 'option' =\> 'SAAB10006'), ), 'prices' =\> array( array( 'customerGroupKey' =\> 'EK', 'price' =\> 1999, ), ) ), ), );

```

Zweiter Update Import:

```
 $updateArticle = array( 'configuratorSet' =\> array( 'groups' =\> array( array( 'name' =\> 'Typ', 'options' =\> array( array('name' =\> 'SAAB10007'), ) ), array( 'name' =\> 'Serie', 'options' =\> array( array('name' =\> '200003'), ) ), ) ), 'taxId' =\> 1, 'variants' =\> array( array( 'isMain' =\> false, 'active' =\> true, 'number' =\> 'SW10020.1', 'inStock' =\> 1, 'position' =\> 1, 'additionaltext' =\> '', 'configuratorOptions' =\> array( array('group' =\> 'Typ', 'option' =\> '200003'), array('group' =\> 'Serie', 'option' =\> 'SAAB10007'), ), 'prices' =\> array( array( 'customerGroupKey' =\> 'EK', 'price' =\> 1999, ), ) ), ), );
```

---

<div class="post-metadata">

### Author: ![Magnum](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Magnum](https://forum.shopware.com/u/Magnum)
#### Post date: [12. Dezember 2018 um 15:29 UTC](https://forum.shopware.com/t/rest-api-varianten-update-fugt-nicht-hinzu-sondern-ersetzt/57014/2 "2018-12-12T15:29:07Z")

</div>

Hallo,

jetzt weiß ich sicher wo der Fehler ist. In der Tabelle&nbsp; **s\_article\_configurator\_set\_option\_relations&nbsp;** werden alle bisherigen einträge komplett gelöscht. Im Anschluss wird hier nur ein Eintrag für den neuste Variante bzw. Varianten angelegt.

Soweit gut, doch wie ich das löse ohne alle Varianten zuvor auszulesen und neu zu importieren weiß ich nicht. Vielleicht hatte hier jemand schonmal ein ähnliches Problem.
