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

**URL:** <https://forum.shopware.com/t/the-shop-service-is-synthetic-it-needs-to-be-set-at-boot-time-before-it-can-be-used-shopware-5-7-13/95380>\
**Category:** Shopware 5\
**Tags:** programming\
**Created:** [20. Juli 2022 um 10:03 UTC](https://forum.shopware.com/t/the-shop-service-is-synthetic-it-needs-to-be-set-at-boot-time-before-it-can-be-used-shopware-5-7-13/95380 "2022-07-20T10:03:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marko.richter](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@marko.richter](https://forum.shopware.com/u/marko.richter)\
**Post date:** [20. Juli 2022 um 10:03 UTC](https://forum.shopware.com/t/the-shop-service-is-synthetic-it-needs-to-be-set-at-boot-time-before-it-can-be-used-shopware-5-7-13/95380/1 "2022-07-20T10:03:23Z")

</div>

Hey,

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.

> synthetic=„true“

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

```auto
 /**
     * @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.

```auto
<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(){
        //Shopware()->Shop();
        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

---

<div class="post-metadata">

**Author:** ![marko.richter](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@marko.richter](https://forum.shopware.com/u/marko.richter)\
**Post date:** [20. Juli 2022 um 10:54 UTC](https://forum.shopware.com/t/the-shop-service-is-synthetic-it-needs-to-be-set-at-boot-time-before-it-can-be-used-shopware-5-7-13/95380/2 "2022-07-20T10:54:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sonic](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/sonic/32/25728_2.png) [@sonic](https://forum.shopware.com/u/sonic)\
**Post date:** [20. Juli 2022 um 11:02 UTC](https://forum.shopware.com/t/the-shop-service-is-synthetic-it-needs-to-be-set-at-boot-time-before-it-can-be-used-shopware-5-7-13/95380/3 "2022-07-20T11:02:07Z")

</div>

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

```php
public function onCollectJsFiles(\Enlight_Event_EventArgs $args)
{
   ...
         $shop = $args->getShop());
   ...
}    

```

---

<div class="post-metadata">

**Author:** ![marko.richter](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@marko.richter](https://forum.shopware.com/u/marko.richter)\
**Post date:** [20. Juli 2022 um 12:11 UTC](https://forum.shopware.com/t/the-shop-service-is-synthetic-it-needs-to-be-set-at-boot-time-before-it-can-be-used-shopware-5-7-13/95380/4 "2022-07-20T12:11:19Z")

</div>

> 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.

> [@\[PLUGIN\]\[EVENTS\]\[Theme\_Compiler\_Collect\_Plugin\_Less|Theme\_Compiler\_Collect\_Plugin\_Javascript\] Wie?](https://forum.shopware.com/t/plugin-events-theme-compiler-collect-plugin-less-theme-compiler-collect-plugin-javascript-wie/52880/5?utm_source=google&utm_medium=cpc&utm_campaign=nb-o04_nrt_dach_de_awareness_performance-max_store-sales&utm_content=maxperformance&gclid=Cj0KCQjwz96WBhC8ARIsAATR250PD07tEjeh1dlJnLpxnzR9Y8bJnrJyiQUA7N5FzftyAkVVkbzH2VkaAkzTEALw_wcB):
>
> Uhh sorry, vor lauter tippen & zippen hab ich doch glatt meine Antwort vergessen… ^^ [@Moritz Naczenski schrieb:](https://forum.shopware.com/profile/14574/Moritz%20Naczenski "Moritz%20Naczenski") Das ist hier im Startup-Guide aber auch alles beschrieben:&nbsp;[https://developers.shopware.com/developers-guide/plugin-quick-start/#extending-the-template](https://developers.shopware.com/developers-guide/plugin-quick-start/#extending-the-template) Ich pick mir davon mal das meines Erachtens wesentlichste heraus: Frontend resources auto-registration[Anchor link for: frontend resources auto registration](https://developers.shopware.com/developers-guide/plugin-quick-start/#frontend-resources-auto-registration) Additions to CSS, LESS and JavaScript resources had to be registered via T…

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

> \<plugin\_dir\>/Resources/frontend/js/

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

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