# Wie kann man related models/tables von Customer in API mit query kriegen?

**URL:** https://forum.shopware.com/t/wie-kann-man-related-models-tables-von-customer-in-api-mit-query-kriegen/47825
**Category:** Programmierung
**Created:** [25. August 2017 um 09:55 UTC](https://forum.shopware.com/t/wie-kann-man-related-models-tables-von-customer-in-api-mit-query-kriegen/47825 "2017-08-25T09:55:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ertuzio](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@ertuzio](https://forum.shopware.com/u/ertuzio)
#### Post date: [25. August 2017 um 09:55 UTC](https://forum.shopware.com/t/wie-kann-man-related-models-tables-von-customer-in-api-mit-query-kriegen/47825/1 "2017-08-25T09:55:39Z")

</div>

Es gibt in&nbsp;shopware/engine/Shopware/Components/Api/Resource/Customer.php die methode getList();

```
public function getList($offset = 0, $limit = 25, array $criteria = [], array $orderBy = [])
    {
        $this->checkPrivilege('read');

        $builder = $this->getListQuery();

        $builder->addFilter($criteria);
        $builder->addOrderBy($orderBy);
        $builder->setFirstResult($offset)
                ->setMaxResults($limit);

        $query = $builder->getQuery();

        $query->setHydrationMode($this->getResultMode());

        $paginator = $this->getManager()->createPaginator($query);

        //returns the total count of the query
        $totalResult = $paginator->count();

        //returns the customer data
        $customers = $paginator->getIterator()->getArrayCopy();

        return ['data' => $customers, 'total' => $totalResult];
    }

```

und die liefert so was zurück:

```
{
    "success": true,
    "data": {
        "0": [
            {
                "number": "20003",
                "id": 1,
                "paymentId": 5,
                "groupKey": "EKCH",
                "shopId": 8,
                "priceGroupId": null,
                "encoderName": "bcrypt",
                "hashPassword": "$2y$10$c9JSaXCVLok6BYRWSo969ezreAbfcRcFPhOo0vFmM4EWmoG2DQQtK",
                "active": true,
                "email": "ah@webworker.de",
                "firstLogin": "2017-06-01T00:00:00+0200",
                "lastLogin": "2017-08-11T10:54:50+0200",
                "accountMode": 0,
                "confirmationKey": "",
                "sessionId": "82fd98497c443b8041fb1761c6108bcc997e58fad8855cc5dba33773ee23b050",
                "newsletter": 0,
                "validation": "0",
                "affiliate": 0,
                "paymentPreset": 0,
                "languageId": "8",
                "referer": "",
                "internalComment": "",
                "failedLogins": 0,
                "lockedUntil": null,
                "salutation": "mr",
                "title": "",
                "firstname": "Max",
                "lastname": "Power",
                "birthday": null
            },
            {
                "number": "20004",
                "id": 2,
                "paymentId": 5,
                "groupKey": "EK",
                "shopId": 1,
                "priceGroupId": null,
                "encoderName": "bcrypt",
                "hashPassword": "$2y$10$OfY7a2TSs1DmJvekWpYGouN6HmrqXAoSOwPZfb2Y4HRuxWEXWEgUW",
                "active": true,
                "email": "ak@webworker.de",
                "firstLogin": "2017-07-13T00:00:00+0200",
                "lastLogin": "2017-07-18T09:36:53+0200",
                "accountMode": 0,
                "confirmationKey": "",
                "sessionId": "abb89c04d57fe7142bb0ce86588dbb4bd383d9af58eb905f39017d5aa3875e97",
                "newsletter": 0,
                "validation": "0",
                "affiliate": 0,
                "paymentPreset": 5,
                "languageId": "1",
                "referer": "",
                "internalComment": "",
                "failedLogins": 0,
                "lockedUntil": null,
                "salutation": "mr",
                "title": "",
                "firstname": "Max",
                "lastname": "Muster",
                "birthday": "1980-07-13T00:00:00+0200"
            }
        ],
        "total": 2
    }
}

```

Und ich möchte alle Verknüpfungen mit allen anderen Tabelen&nbsp;bekommen.

Wie kriegt man die?

---

<div class="post-metadata">

### Author: ![waldicom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/waldicom/32/12881_2.png) [@waldicom](https://forum.shopware.com/u/waldicom)
#### Post date: [26. August 2017 um 10:07 UTC](https://forum.shopware.com/t/wie-kann-man-related-models-tables-von-customer-in-api-mit-query-kriegen/47825/2 "2017-08-26T10:07:21Z")

</div>

Entweder einzlen aufrufen mit /api/customers/id oder API erweitern, und zwar so etwa so, wie das in [getOne()](https://github.com/shopware/shopware/blob/5.3/engine/Shopware/Components/Api/Resource/Customer.php#L108) gemacht ist
