# Enlight\_Controller\_Front\_RouteStartup Shop ID auslesen

**URL:** <https://forum.shopware.com/t/enlight-controller-front-routestartup-shop-id-auslesen/49808>\
**Category:** Programmierung\
**Created:** [1. Dezember 2017 um 10:47 UTC](https://forum.shopware.com/t/enlight-controller-front-routestartup-shop-id-auslesen/49808 "2017-12-01T10:47:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![finkkraft](https://avatars.discourse-cdn.com/v4/letter/f/3bc359/32.png) [@finkkraft](https://forum.shopware.com/u/finkkraft)\
**Post date:** [1. Dezember 2017 um 10:47 UTC](https://forum.shopware.com/t/enlight-controller-front-routestartup-shop-id-auslesen/49808/1 "2017-12-01T10:47:23Z")

</div>

Hallo Community,

ich muss in einem Plugin recht früh (Enlight\_Controller\_Front\_RouteStartup) die Shop ID auslesen. Unter der alten Plugin Struktur bekomme ich die ID wie folgt:&nbsp;

engine/Shopware/Plugins/Local/Frontend/Foo  
engine/Shopware/Plugins/Local/Frontend/Foo/Bootstrap.php

```
public function install()
{
    $this->subscribeEvent('Enlight_Controller_Front_RouteStartup', 'onRouteStartup');
    return true;
}

public function onRouteStartup(\Enlight_Event_EventArgs $args)
{
    $shop_context = $this->get('shopware_storefront.context_service')->getShopContext();
    $shop_id = $shop_context->getShop()->getId();
    exit(\Doctrine\Common\Util\Debug::dump($shop_id));
}

```

Unter der nuen Plugin Struktur erhalte ich folgenden Fehler:

PHP Fatal error: &nbsp;Uncaught Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service “shop”. Did you mean one of these: “customer\_search.dbal.condition.ordered\_in\_shop\_handler”, “customer\_search.dbal.condition.registered\_in\_shop\_handler”, “shop\_page\_menu”, “shopware.api.address”, “shopware.api.article”, “shopware.api.cache”, “shopware.api.category”, “shopware.api.country”, “shopware.api.customer”, “shopware.api.customer\_stream”, “shopware.api.customergroup”, “shopware.api.emotionpreset”, “shopware.api.manufacturer”, “shopware.api.media”, “shopware.api.order”, “shopware.api.propertygroup”, “shopware.api.resource”, “shopware.api.shop”, “shopware.api.translation”, “shopware.api.variant”, “shopware.cache\_manager”, “shopware.captcha.default\_captcha”, “shopware.captcha.honeypot\_captcha”, “shopware.captcha.legacy\_captcha”, “shopware.captcha.no\_captcha”, “shopware.captcha.repository”, “shopware.captcha.validator”, “shopware.components.last\_articles\_subscriber”, "shopware.csrfto in vendor/symfony/dependency-injection/Container.php on line 295

custom/plugins/Foo  
custom/plugins/Foo/Foo.php

```
public static function getSubscribedEvents()
{
    return [
        'Enlight_Controller_Front_RouteStartup' => 'onRouteStartup',
    ];
}

public function onRouteStartup(\Enlight_Event_EventArgs $args)
{
    $shop_context = $this->container->get('shopware_storefront.context_service')->getShopContext(); //Hier wird der Fehler produziert
    $shop_id = $shop_context->getShop()->getId();
    exit(\Doctrine\Common\Util\Debug::dump($shop_id));
}

```

Hat vielleicht jemand eine Idee?  
&nbsp;

---

<div class="post-metadata">

**Author:** ![arnebecker](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@arnebecker](https://forum.shopware.com/u/arnebecker)\
**Post date:** [1. Dezember 2017 um 13:13 UTC](https://forum.shopware.com/t/enlight-controller-front-routestartup-shop-id-auslesen/49808/2 "2017-12-01T13:13:58Z")

</div>

Die Fehlermeldung

You have requested a non-existent service „shop“

passt irgendwie nicht zu deinem Code Schnipsel.

---

<div class="post-metadata">

**Author:** ![finkkraft](https://avatars.discourse-cdn.com/v4/letter/f/3bc359/32.png) [@finkkraft](https://forum.shopware.com/u/finkkraft)\
**Post date:** [1. Dezember 2017 um 13:56 UTC](https://forum.shopware.com/t/enlight-controller-front-routestartup-shop-id-auslesen/49808/3 "2017-12-01T13:56:09Z")

</div>

Testweise habe ich mich mit dem&nbsp;Code mal etwas später eingeklingt, Event:&nbsp;Enlight\_Controller\_Front\_RouteShutdown.

Hier bekomme ich die korrekte Shop ID.

Kann es sein, dass es den ShopContext bei&nbsp;Enlight\_Controller\_Front\_RouteStartup noch gar nicht gibt? Würde mich allerdings wundern, da er unter der alten Plugin Struktur dort schon vorhanden ist.

&nbsp;
