# SW 5.2.3 API/Customers groupKey

**URL:** https://forum.shopware.com/t/sw-5-2-3-api-customers-groupkey/39184
**Category:** Allgemein
**Created:** [19. August 2016 um 09:19 UTC](https://forum.shopware.com/t/sw-5-2-3-api-customers-groupkey/39184 "2016-08-19T09:19:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pino](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/pino/32/14373_2.png) [@pino](https://forum.shopware.com/u/pino)
#### Post date: [19. August 2016 um 09:19 UTC](https://forum.shopware.com/t/sw-5-2-3-api-customers-groupkey/39184/1 "2016-08-19T09:19:24Z")

</div>

Tach zusammen,

mir ist ein Felher aufgefallen der mir die API für unnütz darstellen lässt.

```
$customerData = array(
    'email' => 'email@demo.de',
    'accountMode' => 1,
    'internalComment' => '',
    'groupKey' => 'AM',
    'paymentID' => 36,
    'salutation' => 'mr',
    'firstname' => 'test',
    'lastname' => 'demo',
    'billing' => array(
        'company' => '',
        'salutation' => 'mr',
        'firstname' => 'test',
        'lastname' => 'demo',
        'street' => 'street 26',
        'zipcode' => '12345',
        'city' => 'city',
        'country' => 5,
        'stateID' => 0,
        'phone' => ''
    ),
    'shipping' => array(
        'company' => '',
        'salutation' => 'mr',
        'firstname' => 'test',
        'lastname' => 'demo',
        'street' => 'street 26',
        'zipcode' => '12345',
        'city' => 'city',
        'country' => 5,
        'stateID' => 0,
        'phone' => ''
    )
);
$customerNew = new \Shopware\Components\Api\Resource\Customer();
$customerNew->setManager(Shopware()->Models());
$customer = $customerNew->create($customerData);
// update, damit groupKey EK zu AM wird :(
customer = $customerNew->update($customer->getId(), $customerData);

```

&nbsp;

Wir setzen den Kunden mit der Kundengruppe „AM“.  
Das macht die API auch schön brave, aber dann geht’s an den ‚shopware\_account.register\_service‘ zum speichern.

in&nbsp;[200]

```
$customer->setGroup(
    $this->modelManager->find('Shopware\Models\Customer\Group', $shop->getCustomerGroup()->getId())
);

```

wird die Kundengruppe überschrieben, danke&nbsp; ![Thumb-Up](https://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/thumb-up.png "Thumb-Up")

Wir sind nun gezwungen nach dem speichern den Kunden nochmal anzupacken um Änderungen vor zu nehmen&nbsp; ![Blush](https://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/blush.png "Blush")

&nbsp;

Warum wird in der API die Kundengruppe überschrieben?

---

<div class="post-metadata">

### Author: ![t2oh4e](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@t2oh4e](https://forum.shopware.com/u/t2oh4e)
#### Post date: [21. August 2016 um 11:20 UTC](https://forum.shopware.com/t/sw-5-2-3-api-customers-groupkey/39184/2 "2016-08-21T11:20:50Z")

</div>

Warum: Vermutlich weil der RegisterService nachträglich eingebaut wurde und übersehen wurde, dass dabei die CustomerGroup aus API-Request überschrieben wird. Etwas ärgerlich, aber kein Beinbruch. Insbesondere da du ja die Stelle an der der Fehler auftritt schon ausfindigt gemacht hast.

Ich habe mal einen Fix dafür auf Github als PR eingereicht:&nbsp;[https://github.com/shopware/shopware/pull/670](https://github.com/shopware/shopware/pull/670)

---

<div class="post-metadata">

### Author: ![pino](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/pino/32/14373_2.png) [@pino](https://forum.shopware.com/u/pino)
#### Post date: [22. August 2016 um 10:56 UTC](https://forum.shopware.com/t/sw-5-2-3-api-customers-groupkey/39184/3 "2016-08-22T10:56:43Z")

</div>

![Thumb-Up](https://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/thumb-up.png "Thumb-Up")&nbsp;danke
