FriendsOfShopware/FroshTools

Config overrides in system_config have no effect in api/_action/system-config

Closed this issue · 4 comments

sjerdo commented

PHP Version

8.2.7

Shopware Version

v6.5.3.3

Actual behaviour

We use the BucsItTimeline plugin to show a timeline of order events at the order detail page. We'd like to show this timeline at the bottom of the page. The BucsItTimeline plugin contains configuration options to set the position of the timeline card.

We set this config in frosh_tools.yaml

frosh_tools:
    system_config:
        default:
            BucsItTimeline.config.orderPosition: "bottom"

The override is included in the result of AbstractSystemConfigLoader->load(), but this method is not considered for SystemConfigService->getDomain() which is used by Shopware route /api/_action/system-config in SystemConfigController::getConfigurationValues()

The result for the system-config array includes the default value:

{
    "BucsItTimeline.config.defaultHeight": 600,
    "BucsItTimeline.config.defaultCollapsed": false,
    "BucsItTimeline.config.orderPosition": "top",
    "BucsItTimeline.config.customerPosition": "bottom"
}

Expected behaviour

The result for the system-config API response should include the overridden value for BucsItTimeline.config.orderPosition:

{
    "BucsItTimeline.config.defaultHeight": 600,
    "BucsItTimeline.config.defaultCollapsed": false,
    "BucsItTimeline.config.orderPosition": "bottom",
    "BucsItTimeline.config.customerPosition": "bottom"
}

Steps to Reproduce?

  • Install plugin BucsItTimeline
  • Install FroshTools bundle
  • Set config in config/packages/frosh_tools.yaml:
frosh_tools:
    system_config:
        default:
            BucsItTimeline.config.orderPosition: "bottom"
  • Open an order detail page
  • BucsItTimeline is positioned at the top instead of the bottom.
GET /api/_action/system-config?domain=BucsItTimeline.config HTTP/1.1
Accept: application/vnd.api+json
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8,nl;q=0.7

HTTP/1.1 200 OK
...
Content-Type: application/json
Content-Length: 118

{
    "BucsItTimeline.config.defaultHeight": 600,
    "BucsItTimeline.config.defaultCollapsed": false,
    "BucsItTimeline.config.orderPosition": "top",
    "BucsItTimeline.config.customerPosition": "bottom"
}
shyim commented

Is it just displaying problem?

sjerdo commented

Well, for this plugin it is just a displaying problem. We could override the templates to show the timeline card at the correct position, but we'd rather not override these plugin admin Twig files.

I'm not aware of any other issues, since we don't override that many configuration values. However, all settings retrieved by Admin API method systemConfigApiService.getValues() do only return the configuration from the database and are not overridden by FroshTools ConfigSystemConfigLoader.

This uses \Shopware\Core\System\SystemConfig\SystemConfigService::getDomain. It looks like this can be fixed by subscribing onto SystemConfigDomainLoadedEvent and manipulating the config.

You are welcome to add a PR.

This functionality will be added to the core with Shopware 6.6.4.0, this will work also with getDomain. It's pretty uggly to decorate the SystemConfigService. So I would not implement this here anymore and remove this functionality in future as it will be directly in core