# Angelegtes Freitextfeld unter Artikel Downloads im Frontend einbinden?

**URL:** https://forum.shopware.com/t/angelegtes-freitextfeld-unter-artikel-downloads-im-frontend-einbinden/52310
**Category:** Allgemein
**Created:** [11. April 2018 um 16:20 UTC](https://forum.shopware.com/t/angelegtes-freitextfeld-unter-artikel-downloads-im-frontend-einbinden/52310 "2018-04-11T16:20:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nova-sign](https://avatars.discourse-cdn.com/v4/letter/n/9de0a6/32.png) [@nova-sign](https://forum.shopware.com/u/nova-sign)
#### Post date: [11. April 2018 um 16:20 UTC](https://forum.shopware.com/t/angelegtes-freitextfeld-unter-artikel-downloads-im-frontend-einbinden/52310/1 "2018-04-11T16:20:05Z")

</div>

Hallo,

ich habe in der Freitextfeld Verwaltung unter Artikel-Download (s\_articles\_downloads\_attributes) ein neues Freitextfeld angelegt. Das Feld erscheint auch im Backend und lässt sich auch befüllen. Nur habe ich Probleme, den Wert im Frontend auszugeben. Über den Debugger finde ich das Feld auf der Artikel Detail Seite gar nicht. Es wird mir keine Variable angezeigt. Es müsste&nbsp;doch normalerweise unter sDownloads zu finden sein.&nbsp;Wie kann ich das Feld im Frontend Template einfügen?

Viele Grüße,  
Dirk

---

<div class="post-metadata">

### Author: ![nova-sign](https://avatars.discourse-cdn.com/v4/letter/n/9de0a6/32.png) [@nova-sign](https://forum.shopware.com/u/nova-sign)
#### Post date: [16. April 2018 um 14:07 UTC](https://forum.shopware.com/t/angelegtes-freitextfeld-unter-artikel-downloads-im-frontend-einbinden/52310/2 "2018-04-16T14:07:32Z")

</div>

Hat keiner einen Tipp für mich?

---

<div class="post-metadata">

### Author: ![supermonster](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@supermonster](https://forum.shopware.com/u/supermonster)
#### Post date: [8. Juni 2018 um 15:06 UTC](https://forum.shopware.com/t/angelegtes-freitextfeld-unter-artikel-downloads-im-frontend-einbinden/52310/3 "2018-06-08T15:06:59Z")

</div>

Da ich mich auch gerade damit rumschlagen musste: Im Standard nicht implementiert. Du kommst also nicht um ein Plug-in herum.

Ich hab’ meins mal entschlackt und das hier sollte es tun:

```
container->get('shopware_attribute.crud_service');

        $service->update('s_articles_downloads_attributes', 'my_mime_type', 'string', [
            'label' => 'MIME Type',
            'displayInBackend' => true
        ]);

        $service->update('s_articles_downloads_attributes', 'my_mime_source', 'string', [
            'label' => 'MIME Source',
            'displayInBackend' => true
        ]);

        $service->update('s_articles_downloads_attributes', 'my_mime_descr', 'string', [
            'label' => 'MIME Description',
            'displayInBackend' => true
        ]);

        $service->update('s_articles_downloads_attributes', 'my_mime_purpose', 'string', [
            'label' => 'MIME Purpose',
            'displayInBackend' => true
        ]);
    }
    
    public static function getSubscribedEvents()
    {
        return [
            'Legacy_Struct_Converter_Convert_Product' => 'onLegacyStructConverterConvertProduct'
        ];
    }

    public function onLegacyStructConverterConvertProduct(\Enlight_Event_EventArgs $args)
    {
        $data = $args->getReturn();

        // Add download attributes to product legacy struct
        if (isset($data['sDownloads'])) {
            $downloadIds = array_column($data['sDownloads'], 'id');

            $qb = Shopware()->Models()->getConnection()->createQueryBuilder();
            $qb->select('*')
                ->from('s_articles_downloads_attributes', 'downloadAttributes')
                ->where('downloadAttributes.id IN (:downloadIds)')
                ->setParameter('downloadIds', $downloadIds);
            
            $downloadAttributes = $qb->execute()->fetchAll();

            foreach ($data['sDownloads'] as &$download) {
                $download['attributes'] = [];

                foreach ($downloadAttributes as $downloadAttribute) {
                    if ($download['id'] == $downloadAttribute['downloadID']) {
                        $download['attributes'] = $downloadAttribute;
                    }
                }
            }
        }

        return $data;
    }
}

```

Einfach im Ordner _custom/plugins_ noch einen Ordner _ArticleDownloadsAttributes_ anlegen, dort eine Datei&nbsp;_ArticleDownloadsAttributes.php_ mit dem obigen Inhalt.

**Achtung:** Die entschlackte Version da oben ist ungetestet. Kann sein, dass es dir um die Ohren fliegt.

**Edit:**

Ha! Ganz vergessen, dass du für ein Plug-in ja noch ein, zwei Dateien brauchst.&nbsp; ![Grin](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/70033cde8e8ff79cfa538293ae71318d6f788423.png "Grin")

_plugin.xml_:

```
    Attribute für Artikel-Downloads
    Attributes for article downloads

    1.0.0
    http://supermonster.de
    supermonster
    

    
        Veröffentlichung
        Release

```

Und wenn du ordentlich bist, gehört noch ein _plugin.png_ da rein, 16x16 Pixel.
