# API Search / Includes mit Associations für Product-Entity

**URL:** <https://forum.shopware.com/t/api-search-includes-mit-associations-fuer-product-entity/100033>\
**Category:** Programmierung\
**Created:** [9. Juni 2023 um 16:28 UTC](https://forum.shopware.com/t/api-search-includes-mit-associations-fuer-product-entity/100033 "2023-06-09T16:28:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![grelf111](https://avatars.discourse-cdn.com/v4/letter/g/91b2a8/32.png) [@grelf111](https://forum.shopware.com/u/grelf111)\
**Post date:** [9. Juni 2023 um 16:28 UTC](https://forum.shopware.com/t/api-search-includes-mit-associations-fuer-product-entity/100033/1 "2023-06-09T16:28:05Z")

</div>

Hallo,  
ich brauche Daten für eine Liste, will also sowenig wie möglich abfragen.  
Dafür sind die „includes“ gedacht, aber ich komme damit nicht zurecht.  
Hier die Abfrage aus Postman:

```auto
POST myURL/search/product
{
    "filter": [
        {
            "type": "prefix",
            "field": "productNumber",
            "value": "myNumber"
        }
    ],
    "total-count-mode": 1,
    "page": "1",
    "limit": "5",
    "associations": {
        "crossSellings": {}
    },
    "includes": {
        "tax": [],
        "product_cross_selling": ["id","productId", "name","position","type","active"]
    }
}

```

Das funktioniert, aber ich bekomme immer die komplette Product-Entity mit allen Attributen, Links und Relationships mit geliefert.  
Sobald ich in die „includes“ das Product einfüge, z.B. so:

```auto
POST myURL/search/product
{
...
    },
    "includes": {
          "product":["id", "productNumber"],
          "tax": [],
          "product_cross_selling": ["id","productId", "name","position","type","active"]
    }
}

```

dann bekomme ich nur noch die kurze Product-Entity mit ID und ProductNumber;  
das „product\_cross\_selling“ wird aber nicht mehr mitgeliefert.

Eigentlich erwarte ich ein kurzes json ohne Tax, mit den gefragten Product- und Crossselling Attributen.  
Was stimmt hier nicht - meine Erwartung oder die Abfrage?  
Danke

Ps: wenn ich ‚search‘ nur mit filter und ohne ‚associations‘ machen, kann ich die Attribute der Product-Entity mit ‚includes‘ auswählen.

---

<div class="post-metadata">

**Author:** ![martin.janecki](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@martin.janecki](https://forum.shopware.com/u/martin.janecki)\
**Post date:** [28. Juni 2023 um 05:51 UTC](https://forum.shopware.com/t/api-search-includes-mit-associations-fuer-product-entity/100033/2 "2023-06-28T05:51:13Z")

</div>

Hallo,  
versuch mal crossSellingAssignedProducts ins include von product mit reinzunehmen.

```auto
POST myURL/search/product
{
...
    },
    "includes": {
          "product":["id", "productNumber,crossSellingAssignedProducts"],
          "tax": [],
          "product_cross_selling": ["id","productId", "name","position","type","active"]
    }
}

```

Was bei mir fehlte war die Verbindung in der mainentity zur association im includes. Ich wollte paymentmethod ausgeben im order fehlten mir jedoch die transactions.

Gruß Martin

---

<div class="post-metadata">

**Author:** ![OliverSkroblin](https://avatars.discourse-cdn.com/v4/letter/o/4af34b/32.png) [@OliverSkroblin](https://forum.shopware.com/u/OliverSkroblin)\
**Post date:** [29. Dezember 2023 um 16:42 UTC](https://forum.shopware.com/t/api-search-includes-mit-associations-fuer-product-entity/100033/3 "2023-12-29T16:42:17Z")

</div>

```auto
{
    "page":1,
    "limit":25,
    "ids": ["018cb672df6a72cd8e2567c0af248a2f"],
    "associations": {
        "crossSellings": {}
    },
    "includes": {
        "product": ["id", "tax", "crossSellings"],
        "tax": [],
        "product_cross_selling": ["id","productId", "name","position","type","active"]
    }
}

```

Results into.

```auto
{
    "total": 1,
    "data": [
        {
            "tax": {
                "apiAlias": "tax"
            },
            "crossSellings": [
                {
                    "name": "XX",
                    "position": 1,
                    "active": true,
                    "productId": "018cb672df6a72cd8e2567c0af248a2f",
                    "type": "productList",
                    "id": "018cb673149d72129fa33bfb54f95f2f",
                    "apiAlias": "product_cross_selling"
                }
            ],
            "id": "018cb672df6a72cd8e2567c0af248a2f",
            "apiAlias": "product"
        }
    ],
    "aggregations": []
}

```
