Hello,
it is already mentioned several times here in the forum, but in German, so maybe you couldn’t find it
$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 registerResources is deprecated. Use the shopware.components.shop_registration_service instead.
Best regards from Schöppingen
Michael Telgmann