Search code examples
phptwigshopwareshopware6

Shopware 6: How to Access Config Parameters in Twig Template of the Admin Module


I'm looking for a way to access configuration parameters in twig template of the admin module. I tried to access it by:

{{ shopware.config.pluginName.config.fieldName }}

The problem is that in the twig template of the admin module {{ shopware.config }} isn't available. I tried to access it by {{ dump(shopware.config) }} but it returns nothing. Am I doing something wrong?

Is there alternative to access plugin's configuration parameters in the admin module?

Is there a way to pass php variables to twig template of the admin module?

Thanks in advance,

Cheers!


Solution

  • Try to use following service:

    this.systemConfigApiService.getValues('domain', this.selectedSalesChannelId)
    

    where domain is the Plugin name.

    Of course, you should inject that service first

    inject: ['systemConfigApiService']
    

    Using that service you can provide config value to twig template.