opengento/module-country-store

此模块添加了多个国家与多个商店的关联关系,并将其提供给店面。

2.0.1 2024-07-22 20:05 UTC

This package is auto-updated.

Last update: 2024-09-11 17:25:53 UTC


README

Latest Stable Version License: MIT Packagist Packagist

此模块添加了多个国家与多个商店的关联关系,并将其提供给店面。

设置

需要 Magento 2 Open Source 或 Commerce 版本。

Composer 安装

运行以下 composer 命令

composer require opengento/module-country-store

设置模块

运行以下 magento 命令

bin/magento setup:upgrade

如果处于生产模式,不要忘记重新编译和重新部署静态资源。

功能

国家到商店映射

定义多个国家与多个商店的关系。此配置将允许 Magento 将商店映射到国家。

设置

此模块的配置可在 商店 > 配置 > 常规 > 国家商店 中找到。

文档

如何添加国家解析器

创建一个新的最终类并实现以下接口:Opengento\CountryStore\Api\CountryResolverInterface。方法 public function getCountry(): CountryInterface 应返回依赖于上下文的默认国家。国家代码应符合 ISO 3166-1 alpha-2 格式。

在方法工厂中注册新的国家解析器,Vendor/Module/etc/di.xml

<type name="Opengento\CountryStore\Model\Resolver\ResolverFactory">
    <arguments>
        <argument name="countryResolvers" xsi:type="array">
            <item name="customCountryResolver" xsi:type="string">Vendor\Module\Model\Country\Resolver\CustomCountryResolver</item>
        </argument>
    </arguments>
</type>

如果希望解析器在设置中可用,请将其添加到解析器列表中,Vendor/Module/etc/di.xml

<virtualType name="Opengento\CountryStore\Model\Config\Source\CountryResolver">
    <arguments>
        <argument name="options" xsi:type="array">
            <item name="customCountryResolver" xsi:type="array">
                <item name="label" xsi:type="string" translatable="true">Custom Country Resolver</item>
                <item name="value" xsi:type="const">Vendor\Module\Model\Country\Resolver\CustomCountryResolver::RESOLVER_CODE</item>
            </item>
        </argument>
    </arguments>
</virtualType>

国家解析器已准备好使用。

支持

向问题跟踪器提出新的 请求

作者

  • Opengento 社区 - 负责人 - Twitter Follow
  • Thomas Klein - 维护者 - GitHub followers
  • 贡献者 - 贡献者 - GitHub contributors

许可协议

本项目采用 MIT 许可协议 - 请参阅 LICENSE 详细信息。

这就结束了!