# Wie kann ich auf Freitextfelder mit Smarty zugreifen?

**URL:** <https://forum.shopware.com/t/wie-kann-ich-auf-freitextfelder-mit-smarty-zugreifen/52551>\
**Category:** Programmierung\
**Created:** [23. April 2018 um 17:10 UTC](https://forum.shopware.com/t/wie-kann-ich-auf-freitextfelder-mit-smarty-zugreifen/52551 "2018-04-23T17:10:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sofco](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Sofco](https://forum.shopware.com/u/Sofco)\
**Post date:** [23. April 2018 um 17:10 UTC](https://forum.shopware.com/t/wie-kann-ich-auf-freitextfelder-mit-smarty-zugreifen/52551/1 "2018-04-23T17:10:59Z")

</div>

Ich versuche auf meine eigens erstelleten Freitextfelder (über mein Plugin erstellt) im Frontend über Smarty zuzugreifen.  
Das versuche ich über folgenden Codeschnippsel:

```
{$manufacturer->getAttributes()['core']->get('supplierscustomerid')}

```

Leider funktioniert das überhaupt nicht. Allerdings wenn ich im Controller Listing in die Action manufacturer folgendes paste:

```
print_r($manufacturer->getAttributes()['core']->get('supplierscustomerid'));
die();

```

sehe ich mein Freitextfeld. De facto ist also mein Ansatz mit Smarty überhaupt nicht verkehrt gewesen. Ich habe oft gelesen das Doctrine Unterstriche in Camel-Case  
transformiert, weswegen ich die Namensgebung beim Freitextfeld im lowercase gehalten habe. Naja, es funktioniert nach wie vor leider nicht.  
Über meinen PHP Code im Controller jedoch schon.

Das Freitextfeld füge ich wie folgt hinzu:

```
   public function createAttributes()
    {
        $service = Shopware()->Container()->get('shopware_attribute.crud_service');
        $service->update('s_articles_supplier_attributes', 'supplierscustomerid', 'text', [
            'label' => 'Kundennummer',
            'supportText' => '20016',
 
            //user has the opportunity to translate the attribute field for each shop
            'translatable' => true,
 
            //attribute will be displayed in the backend module
            'displayInBackend' => true,
 
            //numeric position for the backend view, sorted ascending
            'position' => 100,
 
            //user can modify the attribute in the free text field module
            'custom' => false
        ]);
    }

```

Ich wäre für jeden Denkansatz sehr dankbar.  
Vielen Dank.

---

<div class="post-metadata">

**Author:** ![vierpunkt](https://avatars.discourse-cdn.com/v4/letter/v/ec9cab/32.png) [@vierpunkt](https://forum.shopware.com/u/vierpunkt)\
**Post date:** [24. April 2018 um 06:22 UTC](https://forum.shopware.com/t/wie-kann-ich-auf-freitextfelder-mit-smarty-zugreifen/52551/2 "2018-04-24T06:22:42Z")

</div>

Das ist schon fast richtig 😉

```
{$manufacturer->getAttributes('core')->get('supplierscustomerid')}

```

Das core muss als attribut an die funktion getAttributes übergeben werden.

---

<div class="post-metadata">

**Author:** ![Sofco](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Sofco](https://forum.shopware.com/u/Sofco)\
**Post date:** [24. April 2018 um 14:18 UTC](https://forum.shopware.com/t/wie-kann-ich-auf-freitextfelder-mit-smarty-zugreifen/52551/3 "2018-04-24T14:18:21Z")

</div>

Hallo,

Danke für deine Hilfe.

Wenn ich das allerdings so mache, brit die Seite ab zu laden ab der Stelle wo ich das nutze.

Das print\_r von $manufacturer-\>getAttributes() sieht wie folgt aus:

```
Array
(
    [core] => Shopware\Bundle\StoreFrontBundle\Struct\Attribute Object
        (
            [storage:protected] => Array
                (
                    [id] => 1
                    [supplierID] => 1
                    [supplierscustomerid] => 20016
                )
 
        )
 
)

```

&nbsp;

Bitte um Hilfe 😕

---

<div class="post-metadata">

**Author:** ![ahmadsaad](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@ahmadsaad](https://forum.shopware.com/u/ahmadsaad)\
**Post date:** [24. April 2018 um 20:07 UTC](https://forum.shopware.com/t/wie-kann-ich-auf-freitextfelder-mit-smarty-zugreifen/52551/4 "2018-04-24T20:07:31Z")

</div>

Hallo @THCDev‍,

du bruchst nur diese ‘s’ am ende löchen.

&nbsp;

```
{$manufacturer->getAttribute('core')->get('supplierscustomerid')}

```

also&nbsp;getAttribute nicht&nbsp;getAttributes .

VG,

Tel.: +49 755&nbsp;- 183 990 00 | Web:&nbsp;[http://enbit.de/](http://enbit.de/)

---

<div class="post-metadata">

**Author:** ![Sofco](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Sofco](https://forum.shopware.com/u/Sofco)\
**Post date:** [25. April 2018 um 03:15 UTC](https://forum.shopware.com/t/wie-kann-ich-auf-freitextfelder-mit-smarty-zugreifen/52551/5 "2018-04-25T03:15:52Z")

</div>

Hallo,

Vielen vielen Dank für deine Antwort.

Jetzt läuft es 🙂

LG
