Skip to content

2.2.4: Wrong home page loaded in multi store setup  #15245

Closed
@jokeputs

Description

@jokeputs

Preconditions

  1. Magento 2.2.4
  2. Stores > Configuration > General > Web > Url Options > Add Store Code to Urls: Yes
  3. Add two websites with each a store view, for example:
    a. An international website with a store view with store code 'international'. This is your default website.
    b. A website for Belgium with a store view with store code 'nl_be'.
  4. All websites use the same base url, for example: http://demo.shop.com/
  5. Create two CMS pages:
    a. A page that will be the home page for the international store view.
    b. A page that will be the home page for the nl_be store view.
  6. Configure the home pages: Stores > Configuration > General > Web > Default Pages > CMS Home Page:
    a. Use the international home page as your default configuration
    b. Set the nl_be home page for the Belgian website

Steps to reproduce

  1. Visit the nl_be store view: http://demo.shop.com/nl_be/

Expected result

  1. The home page for nl_be will be loaded.

Actual result

  1. The home page for international is loaded.

Possible cause

I've already done some debugging and this commit seems to cause the issue: c18e36b.

Because Magento\Framework\Session\Config\ConfigInterface has been added as a constructor argument to Magento\Framework\App\Response\Http, Magento\Framework\Session\Config will be created during the $bootstrap->createApplication() part of pub/index.php:

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication(\Magento\Framework\App\Http::class);
$bootstrap->run($app);

Next Magento\Framework\Session\Config in its own constructor will call Magento\Framework\App\Config\ScopeConfigInterface to get a configuration value. But the current store has not been determined yet at this point. This will only happen in the $bootstrap->run() part of pub/index.php.

Magento will fallback to the default store and this will cause the $resolvedScopeCodes array in Magento\Framework\App\Config\ScopeCodeResolver to have a wrong value for key null. Which in turn will cause the wrong homepage being loaded for the nl_be store view.

I'm willing to make a pull request for this but I don't see a good solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Format is validGate 1 Passed. Automatic verification of issue format passed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions