Angelegtes Freitextfeld unter Artikel Downloads im Frontend einbinden?

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 doch normalerweise unter sDownloads zu finden sein. Wie kann ich das Feld im Frontend Template einfügen?

Viele Grüße,
Dirk

Hat keiner einen Tipp für mich?

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 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.  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.