2

I am trying to set up my local mac to have 2 stores in 1 magento instance

The main domain (www.mydomain.dev) is working as expected however the french domain (www.mydomain-fr.dev) is not loading and giving me

1 exception(s):
Exception #0 (Exception): Notice: Undefined index: store; in /Users/myuser/Sites/mydomain/vendor/magento/module-store/Model/StoreResolver/ReaderList.php on line 50

Please could anyone advise? My vhost.conf looks like the following if it helps

  <VirtualHost *:443>
            ServerName mydomain.dev
            ServerAlias *.mydomain.dev
            Include "/Users/myuser/Sites/ssl/ssl-shared-cert.inc"
            CustomLog "/Users/myuser/Sites/logs/dev-access_log" combinedmassvhost
            ErrorLog "/Users/myuser/Sites/logs/dev-error_log"

            VirtualDocumentRoot /Users/myuser/Sites/mydomain
        </VirtualHost>

     <VirtualHost *:443>
            ServerName mydomain-fr.dev
            ServerAlias *.mydomain-fr.dev
            Include "/Users/myuser/Sites/ssl/ssl-shared-cert.inc"
            SetEnv MAGE_RUN_CODE frenchstore_view;
            SetEnv MAGE_RUN_TYPE store;
            CustomLog "/Users/myuser/Sites/logs/dev-access_log" combinedmassvhost
            ErrorLog "/Users/myuser/Sites/logs/dev-error_log"

            VirtualDocumentRoot /Users/myuser/Sites/mydomain
        </VirtualHost>

EDIT

If I update the index.php in root from:

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);

To

$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'default'; 
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);

Then the french domain works. Am I meant to be editing the index.php?

The store hierarchy is the following

Main website     UK Store        UK Store View
Main website     French Store    French Store View
3
  • Could you share the hierarchy in terms of websites, stores and views? Jan 21, 2018 at 14:03
  • I have updated the question with in it, hope this helps
    – Goose84
    Jan 21, 2018 at 14:06
  • I could give you an answer... but it would include certain guesswork, could you also add the code (available when you press on the web site, store and store view links available in admin at Stores > All stores) and which is the default? As of now, my guess is that you override whatever you set in htaccess / vhost.conf in index.php; your .dev domain doesn't work - you get the french no matter what? Jan 21, 2018 at 17:30

1 Answer 1

0

In OP post apache vhost config is incorrect

SetEnv MAGE_RUN_CODE frenchstore_view;
SetEnv MAGE_RUN_TYPE store;

Parameters should be in double-quotes and no semicolons.

Correct one:

SetEnv MAGE_RUN_CODE "frenchstore_view"
SetEnv MAGE_RUN_TYPE "store"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.