Description
Preconditions
- Magento 2.2.4
- Stores > Configuration > General > Web > Url Options > Add Store Code to Urls: Yes
- 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'. - All websites use the same base url, for example: http://demo.shop.com/
- 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. - 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
- Visit the nl_be store view: http://demo.shop.com/nl_be/
Expected result
- The home page for nl_be will be loaded.
Actual result
- 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.