imi/magento2-store-switch-all-store-views
Composer 安装命令:
composer require imi/magento2-store-switch-all-store-views
包简介
This module makes all store views available in the store switcher, regardless of their store or website.
README 文档
README
This Magento module extends the default store switcher and displays all store views, regardless of the store or website they're associated to. The default magento store switcher only show the store views which are associated to the currently active store.
It extends the core store switch Magento\Store\Block\Switcher.
By passing \IMI\StoreSwitch\ViewModel\StoreSwitchModel as an argument to the Switcher Block and using the IMI_StoreSwitch::switch/languages.phtml template you can switch between all stores of all websites.
It is possible to enable or disabled the switcher in default, website and store scope. The corresponding acl resource is IMI_StoreSwitch::config.
The switcher is disabled by default, it can be enabled with the config value imi_store_switch/general/enable or in
the admin configuration on Stores > iMi > Store Switch.
Show country code only or country code and name
By default the store switcher looks like this:
There is also an option to only show the country code in the store view. If enabled, the available options will only display the country code, otherwise the name and country code are shown.
With the option enabled, it looks like this:
Restrict switching between websites
You can configure the store switcher to allow switching only between some websites instead of all. To do this, you
need to set the imi_store_switch/general/available_web_sites config variable to the ids of the website you want to allow.
For example:
n98-magerun2 config:store:set --scope websites --scope-id 1 imi_store_switch/general/available_web_sites 1,2
n98-magerun2 config:store:set --scope websites --scope-id 2 imi_store_switch/general/available_web_sites 1,2
n98-magerun2 config:store:set --scope websites --scope-id 3 imi_store_switch/general/available_web_sites 3
This would allow switching between store views of websites with the id 1 and 2, but not 3 (store views within 3 will still work).
By default (if the configuration variable is not set), you can switch to all other websites. Set it to an empty string or null to disallow switching to another website.
Use direct links instead of redirects
You can configure the switcher to use direct links instead of the redirect method. This however only works with stores that do not share an url. You can enable this feature either via the adminpanel under Stores > Settings > Configuration > IMI > Store Switch > General > Use direct Links or by cli:
n98-magerun2 config:store:set imi_store_switch/general/use_direct_links 1
Installing
The easiest way to install the module is from packagist by running
composer require imi/magento2-store-switch-all-store-views bin/magento module:enable IMI_StoreSwitch bin/magento setup:upgrade bin/magento cache:flush
If you're running this on a shop in production mode, run
bin/magento setup:static-content:deploy bin/magento cache:flush
Porto Theme
This has partial support for the Porto Theme, without warranty.
You might want to try this layout update in default.xml of your child theme:
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="porto_header">
<block class="Magento\Store\Block\Switcher" name="store_language" as="store_language" template="IMI_StoreSwitch::switch/languages-porto.phtml">
<arguments>
<argument name="view_model" xsi:type="object">IMI\StoreSwitch\ViewModel\StoreSwitchModel</argument>
</arguments>
<action method="setTemplate" ifconfig="imi_store_switch/general/use_direct_links">
<argument name="template" xsi:type="string">IMI_StoreSwitch::switch/direct/languages-porto.phtml</argument>
</action>
</block>
</referenceContainer>
</body>
</page>
Hyvä Theme
This has partial support for the Hyvä Theme, without warranty.
License
© 2020 iMi digital GmbH. Licensed under MIT.
imi/magento2-store-switch-all-store-views 适用场景与选型建议
imi/magento2-store-switch-all-store-views 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 25.91k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2020 年 02 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 imi/magento2-store-switch-all-store-views 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 imi/magento2-store-switch-all-store-views 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 25.91k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-17

