Configuration

If your are familar with Shopware plugins you might know you can create a simple config.xml file for defining a plugin configuration.

dustin/shopware-utils lets you define more than one config file and automatically installs it's default values. This can be done for plugins and AdditionalBundles. All .xml-files in Resources/config/ (except services.xml and routes.xml) will be considered a config file. If xml-parsing detects a structure other than a typical configuration file, the file is skipped.

Create as many config files as you want in your plugin or bundle:

<bundle-or-plugin-dir> |— Resources |— — config |— — — config.xml |— — — my_additional_config.xml |— — — another_config.xml

Now you are able to use this configuration in services or create a new administration module with a user interface.

Use configuration in services

Configurations can be encapsulated into an object and used as service via dependency injection. dustin/shopware-utils brings a Symfony service which can be used as factory to create a configuration object.

Create a global config object

This will create a new service with the global config config from the bundle or plugin MyPlugin.

Use the config object in a service

Create a config object for sales channels

If you need the configuration for a specific sales channel (especially in storefront services) you can also create a config object which holds one inner config object per sales channel.

Last updated