此刻,我正在尝试配置一个Magento商店,但我的问题是应该有两个商店,分别供零售商和一次供不同语言的最终客户使用。
我不希望使用“将代码存储到URL”功能,因为storeview始终必须具有不同的名称,并且还必须与SEO URL有关。
我为此创建了两个商店:
两个商店都有两个商店视图
以下解决方案已经过测试,但不幸的是没有成功: https://www.dckap.com/blog/how-to-setup-multiple-stores-in-magento2/ https://gist.github.com/thagxt/0f605f0a8a95c79302db0d2f04383788
通过两种解决方案,我都会收到以下消息:
Exception: Notice:
Undefined index: b2b in {path}vendor/magento/module-store/Model/StoreResolver/ReaderList.php on line 50 in {path}vendor/magento/framework/App/ErrorHandler.php:61 Stack trace:
#0 {path}vendor/magento/module-store/Model/StoreResolver/ReaderList.php(50): Magento\Framework\App\ErrorHandler->handler(8, 'Undefined index...', '/html/magentobl...', 50, Array)
#1 {path}vendor/magento/module-store/Model/StoresData.php(64): Magento\Store\Model\StoreResolver\ReaderList->getReader('b2b')
#2 {path}vendor/magento/module-store/Model/StoreResolver.php(138): Magento\Store\Model\StoresData->getStoresData('b2b', 'b2b_de')
#3 {path}vendor/magento/module-store/Model/StoreResolver.php(97): Magento\Store\Model\StoreResolver->getStoresData()
#4 {path}vendor/magento/module-store/Model/StoreManager.php(157): Magento\Store\Model\StoreResolver->getCurrentStoreId() #5 {path}generated/code/Magento/Store/Model/StoreManagerInterface/Proxy.php(119): Magento\Store\Model\StoreManager->getStore(NULL)
#6 {path}vendor/magento/module-store/Model/Resolver/Store.php(30): Magento\Store\Model\StoreManagerInterface\Proxy->getStore(NULL)
#7 {path}vendor/magento/framework/App/Config/ScopeCodeResolver.php(49): Magento\Store\Model\Resolver\Store->getScope(NULL)
#8 {path}vendor/magento/framework/App/Config.php(69): Magento\Framework\App\Config\ScopeCodeResolver->resolve('stores', NULL)
#9 {path}vendor/magento/module-developer/Model/Logger/Handler/Debug.php(63): Magento\Framework\App\Config->getValue('dev/debug/debug...', 'stores')
#10 {path}vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(31): Magento\Developer\Model\Logger\Handler\Debug->isHandling(Array)
#11 {path}vendor/monolog/monolog/src/Monolog/Logger.php(344): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#12 {path}vendor/magento/framework/Logger/Monolog.php(48): Monolog\Logger->addRecord(400, 'Notice: Undefin...', Array)
#13 {path}vendor/monolog/monolog/src/Monolog/Logger.php(707): Magento\Framework\Logger\Monolog->addRecord(400, 'Notice: Undefin...', Array)
#14 {path}vendor/magento/framework/App/Bootstrap.php(263): Monolog\Logger->error('Notice: Undefin...')
#15 {path}de/index.php(42): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor)) #16 {main}
其他人对此有想法吗?
非常感谢
答案 0 :(得分:0)
您应该将2个商店添加为 网站 ,而不是商店:
然后为每个网站添加一个具有相同根类别的商店。
此后,您应该为每个商店添加2个商店视图:英语和西班牙语。您将具有以下结构:
-www.domain.com->store 1->en
-www.domain.com->store 1->sp
-b2b.domain.com->store 2->eng
-b2b.domain.com->store 2->esp
商店视图代码必须唯一,这就是为什么我添加了 eng 和 esp < / strong>获取第二个网站商店的浏览量。
然后在.htaccess中添加以下内容:
SetEnvIf Host ^(.*)domain\.com MAGE_RUN_CODE=en
SetEnvIf Host ^(.*)domain\.com MAGE_RUN_TYPE=store
SetEnvIf Host ^(.*)b2b.domain\.com MAGE_RUN_CODE=eng
SetEnvIf Host ^(.*)b2b.domain\.com MAGE_RUN_TYPE=store
如果要将默认商店视图设置为西班牙语,请从 en 和 eng 更改为 sp 和 esp 。
成功!