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:
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: 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?