Search code examples
shopwareshopware6

Enable/disable a plugin individually per sales channel


We have a plugin with a lot of custom routes, services, decorators, etc. Is there a relatively simple solution to enable/disable the plugin individually per sales channel?

The only solution I found is placing if conditions everywhere, but that would be insane for plugins with the size of my example.

I haven't found anything about that topic here on stack overflow or somewhere else.


Solution

  • That is not easily achievable due to the way the underlying PHP and symfony framework works.

    Especially the PHP opcache and the caching of symfony's DI-Container play a role here. As all requests to your shopware server are answered by the same code base, those caches include your plugin for every sales channel.

    Additionally I would advise against trying to achieve something like that because it can easily lead to inconsistensies between the sales channels.

    But themes can be activated per sales channel, as you want to completely customize the UI/UX for each sales channel, maybe that could be a solution for you, to solve the problem/differences on the theme level.

    The business logic and workflows should be the same for each sales channel, because else you may run into problems where you can't distinguish between the sales channel (e.g. for Admin-API requests).