The "shop" service is synthetic, it needs to be set at boot time before it can be used. Shopware 5.7.13


One of my Addon throws an error on theme compile that says:

The „shop“ service is synthetic, it needs to be set at boot time before it can be used.

It apperently has something to do with a Flag.


The Plugin is using the „Shopware()->Shop()“ to get ‚shop‘
A Shopware funktion that is given.

     * @return \Shopware\Models\Shop\DetachedShop|null
    public function Shop()
        return $this->container->get('shop');

So i replace the call with an inject in to see if it would fix the error.

<argument type="service" id="shop" />

    private $oServiceShop;

    public function __construct(
        Shop $oServiceShop // i also tryed "Shopware\Models\Shop\DetachedShop"
        $this->oServiceShop = $oServiceShop;

    public function getShop(){
        return $this->oServiceShop;

but no luck.
The Problem is really that it gives me nothing about, where the Problem is triggered.
I just know that if i disable the plugin it works and when its on, the error shows on template compile.

Do you guys have any idea on how to like debug this or get clues?
Or maybe you had this Problem before?

Thank you

I disabled and tested, when the compile runs through.
It seems to be a subscriber call

‚Theme_Compiler_Collect_Plugin_Javascript‘ => ‚onCollectJsFiles‘,

It was used to add js files to the frontend, apparently.

When compiling the theme, there is no real shop context inside the controller.

public function onCollectJsFiles(\Enlight_Event_EventArgs $args)
         $shop = $args->getShop());

public function onCollectJsFiles(\Enlight_Event_EventArgs $args)
// empty

The problem goes even so far, that the empty function and the subscriber creates the error on compile.

But i found a way now to fix it.

I removed the subscriber for the js and use the auto include from shopware by placing it in the dir


Now the Error is gone and the js is back on the page. At least i have not found new errors :slight_smile:

Still thank you and i hope this helps others that may get the same issue.