# CustomFields Type = Media - Wie Ausgabe im Storefront?

**URL:** https://forum.shopware.com/t/customfields-type-media-wie-ausgabe-im-storefront/61800
**Category:** Programmierung
**Created:** [16. September 2019 um 19:41 UTC](https://forum.shopware.com/t/customfields-type-media-wie-ausgabe-im-storefront/61800 "2019-09-16T19:41:47Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Moorleiche](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Moorleiche](https://forum.shopware.com/u/Moorleiche)
#### Post date: [16. September 2019 um 19:41 UTC](https://forum.shopware.com/t/customfields-type-media-wie-ausgabe-im-storefront/61800/1 "2019-09-16T19:41:47Z")

</div>

Hello,

im Storefront habe ich lediglich nur Zugriff auf die MediaId. Wie gehe ich am besten damit um?

1. Twig Funktion: Nachteil wäre jeweils ein DB Query pro Element (in meinem Fall sind es die Produkte und Kategorien)

2. CMS Resolver extenden: Ist das überhaupt möglich? - Hier auch ein DB Query pro Element oder kann ich das irgendwie in DAL verwursten?

3. Produkt/Kategorie&nbsp;Entity extenden&nbsp;- Hatte hier schon Probleme da durch zu steigen, aber wahrscheinlich die sinnvollste Lösung oder?

4. Shopware liefert 😉

5. ??? - Bin offen für Vorschläge

LG

---

<div class="post-metadata">

### Author: ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)
#### Post date: [17. September 2019 um 14:13 UTC](https://forum.shopware.com/t/customfields-type-media-wie-ausgabe-im-storefront/61800/2 "2019-09-17T14:13:56Z")

</div>

Hallo,

um welches Element geht es genau? Wenn du nur die mediaId zur Verfügung hast, gehe ich mal davon aus, dass die Media Assoziation nicht vorhanden ist?

Viele Grüße aus Schöppingen

![cool](http://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/shopware.png "cool")&nbsp;Michael Telgmann

---

<div class="post-metadata">

### Author: ![Moorleiche](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Moorleiche](https://forum.shopware.com/u/Moorleiche)
#### Post date: [17. September 2019 um 18:26 UTC](https://forum.shopware.com/t/customfields-type-media-wie-ausgabe-im-storefront/61800/3 "2019-09-17T18:26:19Z")

</div>

[@Michael Telgmann]([http://forum.shopware.com/profile/17553/Michael](http://forum.shopware.com/profile/17553/Michael) Telgmann “Michael Telgmann”)‍

Get um ein CustomField Element. Ich kann ja Medien via CustomFields zuweisen, im Storefront bekomme ich dann jedoch nur die ID. In meinem Bsp. ist es ein CustomField zu einem Produkt. Ist es möglich eine Assoziation in diesem Falle zu ergänzen?

---

<div class="post-metadata">

### Author: ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)
#### Post date: [18. September 2019 um 06:43 UTC](https://forum.shopware.com/t/customfields-type-media-wie-ausgabe-im-storefront/61800/4 "2019-09-18T06:43:51Z")

</div>

Guten Morgen,

Grundsätzlich musst du erstmal dir das Medien Objekt mit Hilfe der ID und dem media\_repository&nbsp;selbst holen. Dann hängt es davon ab, wo du das Media Element brauchst:&nbsp;

- Brauchst du das media Objekt IMMER? Dann registriere dich&nbsp;auf das sales\_channel.product.loaded event.
- Brauchst du es nur auf der Detailseite? Dann registriere dich&nbsp;auf ProductPageLoadedEvent
- Brauchst du es nur in dem Listing Element? Dann registriere dich auf das ProductListingResultEvent (Suche, Suggest, Listing inclusive)
- Brauchst du es in den Produkt Boxen in CMS Seiten? Aktuell nur möglich über sales\_channel.product.loaded event.

Viele Grüße aus Schöppingen

![cool](http://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/shopware.png "cool")&nbsp;Michael Telgmann

---

<div class="post-metadata">

### Author: ![Moorleiche](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Moorleiche](https://forum.shopware.com/u/Moorleiche)
#### Post date: [18. September 2019 um 10:04 UTC](https://forum.shopware.com/t/customfields-type-media-wie-ausgabe-im-storefront/61800/5 "2019-09-18T10:04:38Z")

</div>

[@Michael Telgmann]([http://forum.shopware.com/profile/17553/Michael](http://forum.shopware.com/profile/17553/Michael) Telgmann „Michael Telgmann“)‍

Brauche ich im Listing und in den CMS Produktboxen ;)&nbsp;

Event hört sich natürlich gut an 😛

---

<div class="post-metadata">

### Author: ![11shop](https://avatars.discourse-cdn.com/v4/letter/1/90ced4/32.png) [@11shop](https://forum.shopware.com/u/11shop)
#### Post date: [3. Dezember 2019 um 16:08 UTC](https://forum.shopware.com/t/customfields-type-media-wie-ausgabe-im-storefront/61800/6 "2019-12-03T16:08:31Z")

</div>

[@Michael Telgmann]([http://forum.shopware.com/profile/17553/Michael](http://forum.shopware.com/profile/17553/Michael) Telgmann „Michael Telgmann“)‍ Hallo, ich brauche die Ausgabe auf der Detailseite.&nbsp;

{{ attribute(product.translated.customFields, ‚mein\_custom\_field‘)|sw\_sanitize }}

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

&nbsp;

VG

Amin N.

---

<div class="post-metadata">

### Author: ![mediaciety](https://avatars.discourse-cdn.com/v4/letter/m/ba9def/32.png) [@mediaciety](https://forum.shopware.com/u/mediaciety)
#### Post date: [3. Dezember 2019 um 20:11 UTC](https://forum.shopware.com/t/customfields-type-media-wie-ausgabe-im-storefront/61800/7 "2019-12-03T20:11:48Z")

</div>

auf der produktseite wäre es dann " **page**.product.translated.customFields.mein\_custom\_field"

---

<div class="post-metadata">

### Author: ![11shop](https://avatars.discourse-cdn.com/v4/letter/1/90ced4/32.png) [@11shop](https://forum.shopware.com/u/11shop)
#### Post date: [4. Dezember 2019 um 09:40 UTC](https://forum.shopware.com/t/customfields-type-media-wie-ausgabe-im-storefront/61800/8 "2019-12-04T09:40:11Z")

</div>

@mediaciety‍ Vielen Dank. Jetzt wird aber nur die ID ausgegeben. Mein CustomField ist ein Media-Feld. Wie kann ich den&nbsp;Pfad/Url ausgeben lassen?&nbsp;

&nbsp;

Mit Dump bekomme ich auch nur die ID:{{ dump(page.product.translated.customFields) }}

&nbsp; ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/8/8c5b2bcd18a87ab1bfecda351d27c683db822ad3.png)

---

<div class="post-metadata">

### Author: ![mediaciety](https://avatars.discourse-cdn.com/v4/letter/m/ba9def/32.png) [@mediaciety](https://forum.shopware.com/u/mediaciety)
#### Post date: [5. Dezember 2019 um 08:20 UTC](https://forum.shopware.com/t/customfields-type-media-wie-ausgabe-im-storefront/61800/9 "2019-12-05T08:20:27Z")

</div>

je nachdem. dazu wirst du dich per plugin(chen) da 'reinhängen dürfen und entweder das ganze media-objekt aus dem media.repository fischen dürfen, oder nur den URL. dann kommt’s noch drauf an, wo du das ganze benötigst… (ich hatte just gestern eine ganz ähnliche anforderung :D)  
&nbsp;
