# API Search Product Media resources

**URL:** https://forum.shopware.com/t/api-search-product-media-resources/107795
**Category:** Shopware 6 (German)
**Created:** [26. August 2025 um 11:24 UTC](https://forum.shopware.com/t/api-search-product-media-resources/107795 "2025-08-26T11:24:09Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![R4M](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/r4m/32/9983_2.png) [@R4M](https://forum.shopware.com/u/R4M)
#### Post date: [26. August 2025 um 11:24 UTC](https://forum.shopware.com/t/api-search-product-media-resources/107795/1 "2025-08-26T11:24:09Z")

</div>

Bei der API in Shopware 6.7.1.0 muss ich eben feststellen, dass bei Call ‚/api/search/product-media/‘ das Feld ‘media’ komplett lerr ist. Laut aktueller Beschreibung für SW 6.7 auf

> **[Search for the Product Media resources. | Admin API](https://shopware.stoplight.io/docs/admin-api/512844ec93126-search-for-the-product-media-resources)**
>
> Available since: 6.0.0.0 Powered by Stoplight.

sollte das nicht der Fall sein? Ist das ein Bug in 6.7.1.0?

Der Aufruf sieht dabei wie folgt aus:

```auto
$productId = '019743aba7147390a5b3a9b208e7eabb';

...

{ 
 "filter": [ 
 { "type": "multi", "operator": "and", "queries": [{ "type": "equals", "field": "productId", "value": "' .$productId. '" }] } 
 ] 
}

```

Zurück kommt dann nur:

```auto
...
[createdAt] => 2025-08-26T12:17:40.878+00:00
[updatedAt] => 
[productId] => 019743aba7147390a5b3a9b208e7eabb
[mediaId] => 0196ec54412d736a8aefb476007b1272
[position] => 0
[media] => 
[product] => 
[coverProducts] => 
[customFields] => 
[id] => 0198e65000d574dbb10a2f845cde71e0
[apiAlias] => product_media
...

```

Nachtrag: Das Problem ist wohl auch in SW 6.7.1.2 vorhanden. Eben ausprobiert, kein Inhalt bei Feld ‘media’. Oder gibt es beim Aufruf eine neue Syntax?

---

<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: [26. August 2025 um 12:27 UTC](https://forum.shopware.com/t/api-search-product-media-resources/107795/2 "2025-08-26T12:27:58Z")

</div>

```auto
{
  "associations": {
    "media": {}
  }
}

```

---

<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: [26. August 2025 um 12:38 UTC](https://forum.shopware.com/t/api-search-product-media-resources/107795/4 "2025-08-26T12:38:30Z")

</div>

Ich habe den Titel geändert, da es kein Bug ist, sondern du lediglich die assoiations nicht mit angefordert hast.

```auto
{
  "filter": [
    {
      "type": "multi",
      "operator": "and",
      "queries": [
        {
          "type": "equals",
          "field": "productId",
          "value": "' .$productId. '"
        }
      ]
    }
  ],
  "associations": {
    "media": {}
  }
}

```

---

<div class="post-metadata">

### Author: ![R4M](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/r4m/32/9983_2.png) [@R4M](https://forum.shopware.com/u/R4M)
#### Post date: [26. August 2025 um 12:40 UTC](https://forum.shopware.com/t/api-search-product-media-resources/107795/5 "2025-08-26T12:40:37Z")

</div>

Ok, hab schon hinbekommen. Aber steht diese Info irgendwo in der Doku? Da in SW 6.6 das nicht der Fall war.

---

<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: [26. August 2025 um 12:44 UTC](https://forum.shopware.com/t/api-search-product-media-resources/107795/6 "2025-08-26T12:44:47Z")

</div>

In den allermeisten Fällen muss man associations manuell laden. Nur wenn ein autoload in den Entities festgelegt ist, dann wird die verbundene Entity automatisch geladen.

```auto
(new ManyToOneAssociationField('media', 'media_id', MediaDefinition::class, 'id'))->addFlags(new ApiAware())

```

> <https://github.com/shopware/core/blob/6842bcd45bd93d567ca0bd727db9927bc24938e6/Content/Product/Aggregate/ProductMedia/ProductMediaDefinition.php#L25>

> <https://github.com/shopware/core/commit/c084be0cf92a5f4c7eb34f0f466a22d9d2f88d1a>

---

<div class="post-metadata">

### Author: ![R4M](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/r4m/32/9983_2.png) [@R4M](https://forum.shopware.com/u/R4M)
#### Post date: [26. August 2025 um 13:24 UTC](https://forum.shopware.com/t/api-search-product-media-resources/107795/7 "2025-08-26T13:24:55Z")

</div>

Das ist komisch, denn Shopware bringt eine Fehlermeldung:

```auto
Uncaught PHP Exception Shopware\Core\Framework\DataAbstractionLayer\Exception\AssociationNotFoundException: 
"Can not find association by name media" at FrameworkException.php line 143 

```

---

<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: [26. August 2025 um 13:55 UTC](https://forum.shopware.com/t/api-search-product-media-resources/107795/8 "2025-08-26T13:55:19Z")

</div>

Hast du einen Code-Block zum Fehler?

---

<div class="post-metadata">

### Author: ![R4M](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/r4m/32/9983_2.png) [@R4M](https://forum.shopware.com/u/R4M)
#### Post date: [27. August 2025 um 09:09 UTC](https://forum.shopware.com/t/api-search-product-media-resources/107795/9 "2025-08-27T09:09:18Z")

</div>

Die Fehlermeldung ist wieder weg. Hatte versenhtlich bei einem anderen API-Call ‘associations’ mit angeben, obwohl es hier wohl gar nicht rein gehört. Wäre toll, wenn das in der Doku etwas besser beschrieben würde. Zumal es wohl weitere Änderungen bei der API von SW 6.6 zu SW 6.7 gibt ☹ Aber das Thema hier ist erledigt.

---

<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: [27. August 2025 um 11:01 UTC](https://forum.shopware.com/t/api-search-product-media-resources/107795/10 "2025-08-27T11:01:51Z")

</div>

> [@R4M](#):
>
> Zumal es wohl weitere Änderungen bei der API von SW 6.6 zu SW 6.7 gibt

Das sind keine Änderungen der API. Das sind Änderungen der EntityDefinition, wo ein autoload entfernt wurde. Macht für dich kein Unterschied, ist technisch gesehen aber ein riesiger Unterschied.

Wenn du verknüpfte Daten benötigst, die nicht zum Entity gehören, dann schreib immer die Assoziation mit dazu, egal ob autoload oder nicht. Dann bist du bei Updates sicher.

---

<div class="post-metadata">

### Author: ![R4M](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/r4m/32/9983_2.png) [@R4M](https://forum.shopware.com/u/R4M)
#### Post date: [27. August 2025 um 13:44 UTC](https://forum.shopware.com/t/api-search-product-media-resources/107795/11 "2025-08-27T13:44:39Z")

</div>

Ah ok, soweit alles wieder zum laufen gebracht 🙂

---

<div class="post-metadata">

### Author: ![system](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/3X/2/9/29c7587ba660f00e4995d1743162782e5d6d8653.svg) [@system](https://forum.shopware.com/u/system)
#### Post date: [26. September 2025 um 13:45 UTC](https://forum.shopware.com/t/api-search-product-media-resources/107795/12 "2025-09-26T13:45:33Z")

</div>

Dieses Thema wurde automatisch 30 Tage nach der letzten Antwort geschlossen. Es sind keine neuen Antworten mehr erlaubt.
