Accessing a legacy Shopware plugin from one written for Shopware 5.2

211 views Asked by At

I'm developing a plugin for Shopware 5.2. However, in my application, there are also legacy plugins from before the upgrade to version 5.2.

The documentation tells me to use a call like this in order to access another specific plugin from within my plugin:

$plugin = Shopware()->Container()->get('kernel')->getPlugins()['anotherPlugin'];

Unfortunately, this returns null with legacy plugins, as the method getPlugins() returns an array containing only the plugins written for version 5.2 (those residing in the custom/plugins folder).

How can I deal with this issue?

1

There are 1 answers

1
Edwin On BEST ANSWER

For the legacy Versions you can retrieve the plugins from the container:

Shopware()->Container()->get('plugins')->Backend()->NameOfYourPlugin();

or with Frontend if it is a frontend Plugin

or with Core if it is a Shopware Core Legacy Plugin.

I will suggest you to migrate to the new structure, because this will not be supported for long (if not already with the 5.3).