Skip to content

Update Storefront.php#2

Open
leitge wants to merge 1 commit intotrunkfrom
fix/issue-13387
Open

Update Storefront.php#2
leitge wants to merge 1 commit intotrunkfrom
fix/issue-13387

Conversation

@leitge
Copy link
Owner

@leitge leitge commented Nov 6, 2025

Fixes shopware#13387

1. Why is this change necessary?

Google Analytics does not work in Shopware storefront because the SalesChannelAnalyticsLoader service is never instantiated. This service is responsible for injecting Google Analytics configuration data into storefront templates during the StorefrontRenderEvent. Without this service, the storefrontAnalytics template variable remains undefined, preventing Google Analytics from loading.

2. What does this change do, exactly?

File: src/Storefront/Storefront.php

Change: Adds the missing $loader->load('system.xml') call in the build() method.

public function build(ContainerBuilder $container): void
{
    parent::build($container);
    $this->buildDefaultConfig($container);

    $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/DependencyInjection'));
    $loader->load('services.xml');
    $loader->load('captcha.xml');
    $loader->load('seo.xml');
    $loader->load('controller.xml');
    $loader->load('system.xml');  // ← Added this line
    $loader->load('theme.xml');

    $container->setParameter('storefrontRoot', $this->getPath());

    $container->addCompilerPass(new DisableTemplateCachePass());
    $container->addCompilerPass(new StorefrontMigrationReplacementCompilerPass());
}

This loads the src/Storefront/DependencyInjection/system.xml file which contains the service definition for SalesChannelAnalyticsLoader:

<service id="Shopware\Storefront\System\SalesChannel\SalesChannelAnalyticsLoader">
    <argument type="service" id="sales_channel_analytics.repository"/>
    <tag name="kernel.event_listener" event="Shopware\Storefront\Event\StorefrontRenderEvent" method="loadAnalytics" priority="2000" />
</service>

3. Describe each step to reproduce the issue or behaviour.

  1. Configure Google Analytics in Shopware administration with a valid tracking ID
  2. Set up a sales channel with analytics configuration
  3. Visit any storefront page
  4. Open browser developer tools and check for Google Analytics script loading
  5. Expected: Google Analytics script should be loaded with the configured tracking ID
  6. Actual: No Google Analytics script is loaded because storefrontAnalytics template variable is undefined

4. Please link to the relevant issues (if any).

5. Checklist

  • I have written tests and verified that they fail without my change

  • I have updated developer-facing release notes if this change affects external developers:

    • Add a short entry to RELEASE_INFO-6.<major>.md under "Upcoming" for informational changes.
    • Add an UPGRADE section in UPGRADE-6.<next-major>.md for breaking changes (what/why/impact/how to adapt).
    • See the Release Notes & Changelog Process for details.
  • I have written or adjusted the documentation according to my changes

  • This change has comments for package types, values, functions, and non-obvious lines of code

  • I have read the contribution requirements and fulfilled them


Note: This is a minimal, surgical fix that restores Google Analytics functionality without affecting any other Shopware features. The change is backward compatible and follows Shopware's existing patterns.

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Warnings
⚠️ The Pull Request doesn't contain any release info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Storefront bundle missing system.xml loading prevents SalesChannelAnalyticsLoader service registration

1 participant