# Variable für Shop URL im Backend

**URL:** <https://forum.shopware.com/t/variable-fur-shop-url-im-backend/55148>\
**Category:** Allgemein\
**Created:** [13. September 2018 um 10:13 UTC](https://forum.shopware.com/t/variable-fur-shop-url-im-backend/55148 "2018-09-13T10:13:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kahmoonb](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/kahmoonb/32/19231_2.png) [@Kahmoonb](https://forum.shopware.com/u/Kahmoonb)\
**Post date:** [13. September 2018 um 10:13 UTC](https://forum.shopware.com/t/variable-fur-shop-url-im-backend/55148/1 "2018-09-13T10:13:37Z")

</div>

Hallo zusammen,

&nbsp;

ich betreibe eine Seite mit 4 Shops und würde gerne einen Hersteller Slider machen den ich bei allen einsetzen kann, da es identische URL Strukturen sind. Aktuell kann man leider nur absolute Pfade hinterlegen…relative Pfade lassen sich nicht speichern.

Ich suche daher eine Variable für die Shop URL: **{$urlvariable}** /de/kategorie/

&nbsp;

Leider finde ich irgendwie nichts was ich da verwenden kann.

Jemand ne Idee?

VG Frank

---

<div class="post-metadata">

**Author:** ![PStadtfeld](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@PStadtfeld](https://forum.shopware.com/u/PStadtfeld)\
**Post date:** [13. September 2018 um 10:49 UTC](https://forum.shopware.com/t/variable-fur-shop-url-im-backend/55148/2 "2018-09-13T10:49:26Z")

</div>

```
{$url = {url controller=category} }

```

eventuell? Vielleicht auch controller=Kategorie, müsstest du mal ausprobieren…

Alternativ kannst du auch über Smarty direkt auf die Adresse zugreiffen, das war meine ich sowas:

```
{$smarty.server.HTTP_HOST}

```

oder

```
{$Shop->getHost()}

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![Kahmoonb](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/kahmoonb/32/19231_2.png) [@Kahmoonb](https://forum.shopware.com/u/Kahmoonb)\
**Post date:** [13. September 2018 um 10:58 UTC](https://forum.shopware.com/t/variable-fur-shop-url-im-backend/55148/3 "2018-09-13T10:58:04Z")

</div>

Ich möchte das im URL Feld bei Hersteller im Backend eingeben. Nicht in einem Template. Kann das so leider nicht speichern ☹

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Kahmoonb](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/kahmoonb/32/19231_2.png) [@Kahmoonb](https://forum.shopware.com/u/Kahmoonb)\
**Post date:** [13. September 2018 um 11:39 UTC](https://forum.shopware.com/t/variable-fur-shop-url-im-backend/55148/4 "2018-09-13T11:39:31Z")

</div>

Ich habe beim Hersteller jetzt ein Freitextfeld für eine Custom URL hinzugefügt. Nur irgendwie bekomme ich die nicht ins Temaplte. Ausgegeben wird sie. Das sehe ich mittels

```
{$supplier|@print\_r}

```

&nbsp;

Wie müsste denn die Variable für den Wert von manufactor\_custom\_url lauten?

{$supplier.attributes.core.storage.manufactor\_custom\_url} mag er nicht. Vielleicht weil “Protected”?

Original ist {$supplier.link}

&nbsp;

```
Array
(
    [id] => 19
    [name] => Motorräder - Aprilia - DE
    [description] => 
    [metaTitle] => 
    [metaDescription] => 
    [metaKeywords] => 
    [link] => shopware.php?controller=listing&action=manufacturer&sSupplier=19
    [image] => xxx
    [attributes] => Array
        (
            [core] => Shopware\Bundle\StoreFrontBundle\Struct\Attribute Object
                (
                    [storage:protected] => Array
                        (
                            [id] => 1
                            [supplierID] => 19
                            [manufactor_custom_url] => de/speichenraeder/aprilia
                        )

                )

        )

    [website] => https://www.faba-wheels.com/de/motorraeder-aprilia-de/
)

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![Kahmoonb](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/kahmoonb/32/19231_2.png) [@Kahmoonb](https://forum.shopware.com/u/Kahmoonb)\
**Post date:** [13. September 2018 um 12:08 UTC](https://forum.shopware.com/t/variable-fur-shop-url-im-backend/55148/5 "2018-09-13T12:08:27Z")

</div>

Habe es gelöst: {$supplier.attributes.core-\>get(‘manufactor\_custom\_url’)}

---

<div class="post-metadata">

**Author:** ![atari82](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@atari82](https://forum.shopware.com/u/atari82)\
**Post date:** [13. Februar 2019 um 18:25 UTC](https://forum.shopware.com/t/variable-fur-shop-url-im-backend/55148/6 "2019-02-13T18:25:51Z")

</div>

Ich habe das gleiche Problem in der Datei: …/widgets/emotion/components/component\_category\_teaser.tpl

Ich würde gerne das Kategorie-Freitextfeld “attribute1” in den Einkaufswelten ausgeben:

in der Variable $Data ist es drin:&nbsp;{$Data.category|@print\_r}

```
Shopware\Bundle\StoreFrontBundle\Struct\Category Object
(
    [id:protected] => 13
    [parentId:protected] => 200
    [position:protected] => 1
    [path:protected] => Array
        (
            [0] => 3
            [1] => 200
        )

    [name:protected] => Ordnung
    [metaTitle:protected] => 
    [metaKeywords:protected] => 
    [metaDescription:protected] => 
    [cmsHeadline:protected] => 
    [cmsText:protected] => 
    [template:protected] => 
    [blog:protected] => 
    [displayFacets:protected] => 1
    [displayInNavigation:protected] => 1
    [externalLink:protected] => 
    [externalTarget:protected] => 
    [media:protected] => 
    [blockedCustomerGroupIds:protected] => Array
        (
        )

    [productBoxLayout:protected] => 
    [productStream:protected] => 
    [hideSortings:protected] => 
    [attributes:protected] => Array
        (
            [core] => Shopware\Bundle\StoreFrontBundle\Struct\Attribute Object
                (
                    [storage:protected] => Array
                        (
                            [id] => 1
                            [categoryID] => 13
                            [attribute1] => Sortimentskästen, Koffer, System-/Lagerboxen
                            [attribute2] => 
                            [attribute3] => 
                            [attribute4] => 
                            [attribute5] => 
                            [attribute6] => 
                        )

                )

        )

)
1

```

Das “Sortimentskästen, Koffer, System-/Lagerboxen”.

&nbsp;

{$Data.category-\>get(‘attribute1’)}

{$Data.category-\>get(‘core’)|@print\_r}

{$Data.category-\>get(‘attributes’)|@print\_r}

etc.

funktioniert nicht.

&nbsp;

Wie funktioniert -\>get bei _protected_ genau?

Hat jemand eine Idee?

Danke.

&nbsp;

:-)&nbsp;

---

<div class="post-metadata">

**Author:** ![shyim](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/shyim/32/7681_2.png) [@shyim](https://forum.shopware.com/u/shyim)\
**Post date:** [13. Februar 2019 um 19:08 UTC](https://forum.shopware.com/t/variable-fur-shop-url-im-backend/55148/7 "2019-02-13T19:08:05Z")

</div>

{$Data.category.attributes.core-\>get(‘attribute1’)}

---

<div class="post-metadata">

**Author:** ![simkli](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/simkli/32/13124_2.png) [@simkli](https://forum.shopware.com/u/simkli)\
**Post date:** [13. Februar 2019 um 19:10 UTC](https://forum.shopware.com/t/variable-fur-shop-url-im-backend/55148/8 "2019-02-13T19:10:43Z")

</div>

Hallo @atari82‍ ,

ja, das ist etwas kompliziert. Zunächst mal die Lösung:

```
{* möglich, führt jedoch zu Fehlern, wenn es das Attribut nicht gibt *}
{$Data.category->getAttribute('core')->get('attribute1')}

{* Besser: *}
{if $Data.category->hasAttribute('core') && $Data.category->getAttribute('core')->exists('attribute1')}
    {$Data.category->getAttribute('core')->get('attribute1')}
{/if}

```

Und falls es dich interessiet, hier die Erklärung, wie man darauf kommt ![Wink](https://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/wink.png "Wink"):

1. Du siehst ganz oben bei deinem {$Data.category|print\_r}, dass es sich um ein Objekt der Klasse [Shopware\Bundle\StoreFrontBundle\Struct\Category](https://github.com/shopware/shopware/blob/5.5/engine/Shopware/Bundle/StoreFrontBundle/Struct/Category.php) handelt.
2. Dort findest du keine Methode namens „getAttribute“, diese wird vererbt. class Category **extends** Extendable
3. In der [Extenable](https://github.com/shopware/shopware/blob/5.5/engine/Shopware/Bundle/StoreFrontBundle/Struct/Extendable.php)-Klasse finden wir die nötigen Methoden („hasAttribute“ und „getAttribute“).
4. Die getAttribute gibt uns ein Objekt vom Typ [Attribut](https://github.com/shopware/shopware/blob/5.5/engine/Shopware/Bundle/StoreFrontBundle/Struct/Attribute.php) zurück.
5. In diesem Objekt haben wir dann die Methoden „exists“ und „get“ zur Verfügung. Mit "get(‚nameDesAttributs‘) erhalten wir endlich den Wert.

Viele Grüße

---

<div class="post-metadata">

**Author:** ![atari82](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@atari82](https://forum.shopware.com/u/atari82)\
**Post date:** [13. Februar 2019 um 20:34 UTC](https://forum.shopware.com/t/variable-fur-shop-url-im-backend/55148/9 "2019-02-13T20:34:15Z")

</div>

_Chapeau!!_ Sehr schön erklärt … und funktioniert perfekt!
