# Produktbilder zuordnen

**URL:** <https://forum.shopware.com/t/produktbilder-zuordnen/62790>\
**Category:** Programmierung\
**Created:** [4. November 2019 um 16:25 UTC](https://forum.shopware.com/t/produktbilder-zuordnen/62790 "2019-11-04T16:25:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliverriske](https://avatars.discourse-cdn.com/v4/letter/o/ebca7d/32.png) [@oliverriske](https://forum.shopware.com/u/oliverriske)\
**Post date:** [4. November 2019 um 16:25 UTC](https://forum.shopware.com/t/produktbilder-zuordnen/62790/1 "2019-11-04T16:25:21Z")

</div>

Ich habe es geschafft per API Bilder in den Media Folder zu laden und will nun per API Bilder zu Produktenzuordnen

POST:&nbsp;[http://shopware6-dev1.dev4/api/v1/product-media](http://shopware6-dev1.dev4/api/v1/product-media)

PAYLOAD:

&nbsp;{  
&nbsp;&nbsp; &nbsp;„productId“: „7ca1584054d04bb89b45721ab75edbcd“,  
&nbsp; &nbsp; „mediaId“: „00887e44603e4375a7da68c40e38a781“,  
&nbsp; &nbsp; „position“: 0  
&nbsp;}

lädt das Bild zwar hoch, es ist dann aber nicht als Coverbild aktiv.

Wie erzeuge / setze ich die coverID?

&nbsp;

---

<div class="post-metadata">

**Author:** ![Krispin](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/krispin/32/12849_2.png) [@Krispin](https://forum.shopware.com/u/Krispin)\
**Post date:** [5. November 2019 um 06:55 UTC](https://forum.shopware.com/t/produktbilder-zuordnen/62790/2 "2019-11-05T06:55:20Z")

</div>

Guten Morgen Oliverriske,

hierzu muss du beim Produkt die „coverId“ setzen, diese ID ist dann die MediaId des Coverbildes.

Gruß

Krispin

---

<div class="post-metadata">

**Author:** ![nightfox](https://avatars.discourse-cdn.com/v4/letter/n/c89c15/32.png) [@nightfox](https://forum.shopware.com/u/nightfox)\
**Post date:** [8. November 2019 um 11:09 UTC](https://forum.shopware.com/t/produktbilder-zuordnen/62790/3 "2019-11-08T11:09:36Z")

</div>

I guess something like this,

$product = [

&nbsp; &nbsp; &nbsp; „cover“ =\>&nbsp;[  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;„mediaId“ =\> „e01e9ffb8d284f938afc7a51d343ee96“  
&nbsp; &nbsp; &nbsp; &nbsp;],  
&nbsp; &nbsp; &nbsp; „media“ =\> [  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;„mediaId“ =\> „125ae9b023414c1e9fa87038212bf529“,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;„position“ =\> 1  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;],  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;„mediaId“ =\> „f1003a00c4154a9f83518b2e0e0f309d“,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;„position“ =\> 2  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]  
&nbsp; &nbsp; &nbsp;]  
]
