I've got Shopware 5 plugin which adds some js code to the shop's template. There is main shop_id = 1 and subshop shop_id = 3, and when I configure plugins there is separate configuration for each shop at backend > configuration > plugin_manager > plugin > configuration.
When I check it inside the db table s_core_config_values I see that there are two different configurations added for each shop_id.
In main pugin file I've got a subscriber method, where I'm getting my plugin configuration and then register some events, for example
public static function getSubscribedEvents()
{
return [
'Enlight_Controller_Action_PostDispatchSecure_Frontend' => 'doSthMethod',
];
}
But the problem is that there is always the main plugin configuration (the one for shop_id = 1 even if I'm on my subshop. In my main plugin file
class Shopware_Plugins_Backend_Pluginname_Bootstrap extends Shopware_Components_Plugin_Bootstrap
there is $config = $this->Config(); which always returns main shop configuration, so is there any way to get actual subshop configuration?
EDIT:
I've tried the solution from the 1st answer, but still, no matter what sub shop I'm making the request from, I'm getting my main shop returned when:
$this->container->get('models')->getRepository(\Shopware\Models\Shop\Shop::class)->getActiveDefault();
And with main shop returned I'm getting default store configuration from:
$this->container->get('shopware.plugin.cached_config_reader')->getByPluginName('PluginName', $shop);
When I call:
$this->container->get('models')->getRepository(\Shopware\Models\Shop\Shop::class)->getActiveShops();
Then I get list with all my shops, including sub shops, but I can't distinguish which sub shop the request came from.