# Theme ID von salesChannelEntity bekommen

**URL:** <https://forum.shopware.com/t/theme-id-von-saleschannelentity-bekommen/104330>\
**Category:** Programmierung\
**Created:** [20. Juni 2024 um 08:59 UTC](https://forum.shopware.com/t/theme-id-von-saleschannelentity-bekommen/104330 "2024-06-20T08:59:45Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![art2media](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/art2media/32/22881_2.png) [@art2media](https://forum.shopware.com/u/art2media)\
**Post date:** [20. Juni 2024 um 08:59 UTC](https://forum.shopware.com/t/theme-id-von-saleschannelentity-bekommen/104330/1 "2024-06-20T08:59:45Z")

</div>

Hi,

ich brauche die aktive Theme ID des sales channels.

salesChannelEntity wird als Parameter von der Funktion erwartet. Es handelt sich um eine Twig-Erweiterung.

Ich stell das gesamte Internet auf den Kopf, um an diese kleine Info zu kommen …

Bitte, weiß jemand wie ich die Theme ID von einer salesChannelEntity erhalte?

---

<div class="post-metadata">

**Author:** ![flundi81](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/flundi81/32/24725_2.png) [@flundi81](https://forum.shopware.com/u/flundi81)\
**Post date:** [20. Juni 2024 um 09:04 UTC](https://forum.shopware.com/t/theme-id-von-saleschannelentity-bekommen/104330/2 "2024-06-20T09:04:05Z")

</div>

Hallo,  
muss es unbedingt die Theme ID sein?  
Was genau möchtest du machen?  
Ich hab teils dies Verwendet:  
{% set activeDomainUrl = app.request.get(‚sw-storefront-url‘) %}  
{% if activeDomainUrl == ‚[https://www.shopdomain.de](https://www.shopdomain.de)‘ %}  
{%else%}  
{%endif%}

---

<div class="post-metadata">

**Author:** ![art2media](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/art2media/32/22881_2.png) [@art2media](https://forum.shopware.com/u/art2media)\
**Post date:** [20. Juni 2024 um 09:09 UTC](https://forum.shopware.com/t/theme-id-von-saleschannelentity-bekommen/104330/3 "2024-06-20T09:09:57Z")

</div>

Danke für deine schnelle Antwort.

Ich will in einem Mail Template die Theme-Konfiguration laden, um konfigurierte Farben zu verwenden. Viel wurde probiert, bis ich mit Hilfe von ChatGPT hier hängen geblieben bin:

```php
    public function themeConfig(string $themeId, Context $context)
    {
        return $this->themeService->getThemeConfiguration($themeId, false, $context);
    }

```

Ich hab die Theme ID derzeit statisch drin, aber die soll natürlich dynamisch sein. Statt $themeId kann ich auch $salesChannel übergeben. Jetzt muss ich von besagtem $salesChannel „nur“ die Theme ID holen. ChatGPT spuckt leider Code aus, der nicht funktioniert.

Das Teil kann halt auch nur mit den spärlichen Infos arbeiten …

---

<div class="post-metadata">

**Author:** ![flundi81](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/flundi81/32/24725_2.png) [@flundi81](https://forum.shopware.com/u/flundi81)\
**Post date:** [20. Juni 2024 um 09:13 UTC](https://forum.shopware.com/t/theme-id-von-saleschannelentity-bekommen/104330/4 "2024-06-20T09:13:02Z")

</div>

Wens du im VK bist, steht in der URL die salesChannel ID  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/3X/7/6/76fee02953a2c45c913e1b791935cb3e7f09c791.png)

bei theme genau so:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/3X/c/9/c949228c81c444f17c3f54c2560c8a377a435210.png)

---

<div class="post-metadata">

**Author:** ![art2media](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/art2media/32/22881_2.png) [@art2media](https://forum.shopware.com/u/art2media)\
**Post date:** [20. Juni 2024 um 09:16 UTC](https://forum.shopware.com/t/theme-id-von-saleschannelentity-bekommen/104330/5 "2024-06-20T09:16:05Z")

</div>

Ja, darüber hab ich mir die ID bereits geholt. Ich will sie aber nicht manuell in die Twig-Funktion schreiben. Das Mail Template wird für alle Verkaufskanäle benutzt und soll dementsprechend immer andere Farben haben (die des jeweils aktiven Themes eben).

So verwende ich die Funktion derzeit:

```auto
{{ themeConfig('[Theme UUID]', context).fields['sw-color-brand-secondary'].value }}

```

---

<div class="post-metadata">

**Author:** ![R4M](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/r4m/32/9983_2.png) [@R4M](https://forum.shopware.com/u/R4M)\
**Post date:** [20. Juni 2024 um 09:59 UTC](https://forum.shopware.com/t/theme-id-von-saleschannelentity-bekommen/104330/6 "2024-06-20T09:59:00Z")

</div>

Hm, im Twig kann die ID ganz einfach ermittelt werden:

> {{ themeId }}

---

<div class="post-metadata">

**Author:** ![art2media](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/art2media/32/22881_2.png) [@art2media](https://forum.shopware.com/u/art2media)\
**Post date:** [20. Juni 2024 um 10:01 UTC](https://forum.shopware.com/t/theme-id-von-saleschannelentity-bekommen/104330/7 "2024-06-20T10:01:16Z")

</div>

> [@R4M](#):
>
> themeId

Danke für deine Antwort. Diese Variable ist leider nicht im Mail Template verfügbar.

Diese Info erwähne ich erst in meinem zweiten Post, sorry. Wusste nicht, dass es außerhalb des Mail Templates so eine Variable gibt.

---

<div class="post-metadata">

**Author:** ![R4M](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/r4m/32/9983_2.png) [@R4M](https://forum.shopware.com/u/R4M)\
**Post date:** [20. Juni 2024 um 10:02 UTC](https://forum.shopware.com/t/theme-id-von-saleschannelentity-bekommen/104330/8 "2024-06-20T10:02:20Z")

</div>

> [@art2media](#):
>
> Diese Variable ist leider nicht im Mail Template verfügbar.

Achso, OK, dann falsch gelesen.

---

<div class="post-metadata">

**Author:** ![art2media](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/art2media/32/22881_2.png) [@art2media](https://forum.shopware.com/u/art2media)\
**Post date:** [20. Juni 2024 um 10:05 UTC](https://forum.shopware.com/t/theme-id-von-saleschannelentity-bekommen/104330/9 "2024-06-20T10:05:02Z")

</div>

Ich habe ein Ticket in GitHub erstellt, um das Problem der lückenhaften Dokumentation anzugehen: [Missing docs: Get active theme id from sales channel entity · Issue #1418 · shopware/docs · GitHub](https://github.com/shopware/docs/issues/1418)

Vielleicht bringt’s ja was.

Edit: Hab die Lösung gefunden und im GitHub Issue dokumentiert.

---

<div class="post-metadata">

**Author:** ![area-net-gmbh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/area-net-gmbh/32/21995_2.png) [@area-net-gmbh](https://forum.shopware.com/u/area-net-gmbh)\
**Post date:** [20. Juni 2024 um 13:30 UTC](https://forum.shopware.com/t/theme-id-von-saleschannelentity-bekommen/104330/10 "2024-06-20T13:30:39Z")

</div>

Du musst den Mail Service dekorieren, dort die Theme ID ermitteln und an das Template übergeben:

> **[Add Data to Mails | Shopware Documentation](https://developer.shopware.com/docs/guides/plugins/plugins/content/mail/add-data-to-mails.html)**
>
> Documentation for Shopware developers

---

<div class="post-metadata">

**Author:** ![art2media](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/art2media/32/22881_2.png) [@art2media](https://forum.shopware.com/u/art2media)\
**Post date:** [20. Juni 2024 um 13:37 UTC](https://forum.shopware.com/t/theme-id-von-saleschannelentity-bekommen/104330/11 "2024-06-20T13:37:56Z")

</div>

Ist auch eine Möglichkeit. Dieses Ermitteln der Theme-ID war eben das Problem.

In dem GitHub-Issue wird unter anderem die Lösung diskutiert.

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/3X/2/9/29c7587ba660f00e4995d1743162782e5d6d8653.svg) [@system](https://forum.shopware.com/u/system)\
**Post date:** [20. Juli 2024 um 13:38 UTC](https://forum.shopware.com/t/theme-id-von-saleschannelentity-bekommen/104330/12 "2024-07-20T13:38:14Z")

</div>

Dieses Thema wurde automatisch 30 Tage nach der letzten Antwort geschlossen. Es sind keine neuen Antworten mehr erlaubt.
