# BildId für die CoverId

**URL:** <https://forum.shopware.com/t/bildid-fur-die-coverid/64360>\
**Category:** Programmierung\
**Created:** [30. Januar 2020 um 12:46 UTC](https://forum.shopware.com/t/bildid-fur-die-coverid/64360 "2020-01-30T12:46:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Urs\_Landis](https://avatars.discourse-cdn.com/v4/letter/u/3be4f8/32.png) [@Urs\_Landis](https://forum.shopware.com/u/Urs_Landis)\
**Post date:** [30. Januar 2020 um 12:46 UTC](https://forum.shopware.com/t/bildid-fur-die-coverid/64360/1 "2020-01-30T12:46:19Z")

</div>

Hallo

Ich lege in SW6 per API einen Artikel an und gebe dem die MediaId für das Bild mit auf den Weg. Dann kriegt das Bild nochmals eine Id und diese sollte der coverId zugewiesen werden.

Doch wie komme ich an diese id heran? Die wird sonst niergends zurückgegeben, sondern immer nur die mediaId .&nbsp; ![Money-Mouth](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/74f5bc64b385cf8fea59079171e7f2c493b22cef.png "Money-Mouth")

Oder muss ich die selber generieren und mitgeben? Würde das ungerne tun, aber ich sehe im Moment keinen anderen Weg…

Hat da jemand einen Tip für mich?

&nbsp;

Grüsse

&nbsp;

Urs

---

<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:** [30. Januar 2020 um 12:53 UTC](https://forum.shopware.com/t/bildid-fur-die-coverid/64360/2 "2020-01-30T12:53:39Z")

</div>

**POST:**

Bei Product Post generiere ich eine neue ID

&nbsp;$data[‘coverId’]&nbsp;=&nbsp;md5($product[“identifier”]&nbsp;.&nbsp;$productImage[‘id’],&nbsp;false);

**PATCH:**

Bei Product Patch nehme ich die, die schon da war, wenn es bislang keine gab generiere ich eine.

if (array\_key\_exists(‘coverId’,$originalProduct)) {

&nbsp; &nbsp; $data[‘coverId’]&nbsp;=&nbsp;$originalProduct[‘coverId’];

} else {

&nbsp; &nbsp; &nbsp;$data[‘coverId’]&nbsp;=&nbsp;md5($product[“identifier”]&nbsp;.&nbsp;$productImage[‘id’],&nbsp;false);

}

---

<div class="post-metadata">

**Author:** ![Urs\_Landis](https://avatars.discourse-cdn.com/v4/letter/u/3be4f8/32.png) [@Urs\_Landis](https://forum.shopware.com/u/Urs_Landis)\
**Post date:** [30. Januar 2020 um 14:55 UTC](https://forum.shopware.com/t/bildid-fur-die-coverid/64360/3 "2020-01-30T14:55:19Z")

</div>

Ja, so habe ich es jetzt auch gemacht, danke!

&nbsp;

Weiss jemand wie man dem Product direct die Visibility mitgeben kann, oder muss man das als eigener Requeat machen?

&nbsp;

---

<div class="post-metadata">

**Author:** ![Urs\_Landis](https://avatars.discourse-cdn.com/v4/letter/u/3be4f8/32.png) [@Urs\_Landis](https://forum.shopware.com/u/Urs_Landis)\
**Post date:** [30. Januar 2020 um 15:02 UTC](https://forum.shopware.com/t/bildid-fur-die-coverid/64360/4 "2020-01-30T15:02:17Z")

</div>

Hab’s gefunden…

“visibilities”: [

{

“salesChannelId”: “6a3a3674bba04388bd3f5eeddfcbceb2”,

“visibility”: 30

}

],

&nbsp;

Aber weiss jemand was die 30 soll?

---

<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:** [30. Januar 2020 um 15:05 UTC](https://forum.shopware.com/t/bildid-fur-die-coverid/64360/5 "2020-01-30T15:05:58Z")

</div>

&nbsp;$data[‘visibilities’]&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“salesChannelId”&nbsp;=\>&nbsp;$channel[‘id’],

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“visibility”&nbsp;=\>&nbsp;30,

&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;];

---

<div class="post-metadata">

**Author:** ![Urs\_Landis](https://avatars.discourse-cdn.com/v4/letter/u/3be4f8/32.png) [@Urs\_Landis](https://forum.shopware.com/u/Urs_Landis)\
**Post date:** [30. Januar 2020 um 15:08 UTC](https://forum.shopware.com/t/bildid-fur-die-coverid/64360/6 "2020-01-30T15:08:03Z")

</div>

Aber was bedeutet die 30?

---

<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:** [30. Januar 2020 um 15:13 UTC](https://forum.shopware.com/t/bildid-fur-die-coverid/64360/7 "2020-01-30T15:13:25Z")

</div>

Mit Dokumentation hat es Shopware nicht so…

…alles Forschung und Reverse Engineering

Leider

---

<div class="post-metadata">

**Author:** ![Urs\_Landis](https://avatars.discourse-cdn.com/v4/letter/u/3be4f8/32.png) [@Urs\_Landis](https://forum.shopware.com/u/Urs_Landis)\
**Post date:** [30. Januar 2020 um 15:17 UTC](https://forum.shopware.com/t/bildid-fur-die-coverid/64360/8 "2020-01-30T15:17:59Z")

</div>

Eigentlich müsste Shopware uns ja auf Händen tragen, denn wir sind Multiplikatoren, bei der Doku fühle ich mich eher wie mit Füssen getreten!

Aber ob jetzt Hände oder Füsse, sind ja beides Extremitäten, wer will da schon Kleinlich sein?!?!?&nbsp; ![Wearing-Sunglasses](https://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/wearing-sunglasses.png "Wearing-Sunglasses")

---

<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:** [30. Januar 2020 um 15:19 UTC](https://forum.shopware.com/t/bildid-fur-die-coverid/64360/9 "2020-01-30T15:19:21Z")

</div>

![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/d/d38ee6bac3c24f472252e8061fd962c75ed95720.png)

---

<div class="post-metadata">

**Author:** ![Urs\_Landis](https://avatars.discourse-cdn.com/v4/letter/u/3be4f8/32.png) [@Urs\_Landis](https://forum.shopware.com/u/Urs_Landis)\
**Post date:** [30. Januar 2020 um 15:22 UTC](https://forum.shopware.com/t/bildid-fur-die-coverid/64360/10 "2020-01-30T15:22:07Z")

</div>

Du bist GUT!
