# How to use shop instance in CLI context?

**URL:** https://forum.shopware.com/t/how-to-use-shop-instance-in-cli-context/60286
**Category:** Plugins
**Created:** [4. Juli 2019 um 11:10 UTC](https://forum.shopware.com/t/how-to-use-shop-instance-in-cli-context/60286 "2019-07-04T11:10:55Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)
#### Post date: [18. Juli 2019 um 08:28 UTC](https://forum.shopware.com/t/how-to-use-shop-instance-in-cli-context/60286/4 "2019-07-18T08:28:09Z")

</div>

Hello,

it is already mentioned several times here in the forum, but in German, so maybe you couldn’t find it&nbsp; ![Smile](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/bac5f5766b6a20565a8fb995345b4e41d24daac0.png "Smile")

```
$repository = Shopware()->Container()->get('models')->getRepository(Shopware\Models\Shop\Shop::class);
$shopId = 1; // use your correct shop ID here
$shop = $repository->getActiveById($shopId);
$shop->registerResources();
$context = \Shopware\Components\Routing\Context::createFromShop(
    $shop,
    Shopware()->Container()->get('config')
);

```

Attention here: Since Shopware 5.6 the&nbsp;registerResources is deprecated. Use the&nbsp;shopware.components.shop\_registration\_service instead.&nbsp;

Best regards from Schöppingen

![cool](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/86c57fbace799dd4eb1f1b8a2d3bdc1733f0aea1.png "cool")&nbsp;Michael Telgmann

---

_[View the full topic](https://forum.shopware.com/t/how-to-use-shop-instance-in-cli-context/60286)._
