承接 opengento/module-country-store-redirect 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

opengento/module-country-store-redirect

Composer 安装命令:

composer require opengento/module-country-store-redirect

包简介

This module will redirect the customers regarding their country of origin, on their first visit session.

README 文档

README

Latest Stable Version License: MIT Packagist Packagist

This module will redirect the customers regarding their country of origin, on their first visit session.

Setup

Magento 2 Open Source or Commerce edition is required.

Composer installation

Run the following composer command:

composer require opengento/module-country-store-redirect

Setup the module

Run the following magento command:

bin/magento setup:upgrade

If you are in production mode, do not forget to recompile and redeploy the static resources.

Varnish Usage

Update the varnish vcl with the following instruction:

# Bypass first visit and redirect
if (req.http.cookie !~ "PHPSESSID=") {
    return (pass);
}

Features

First Session Redirect

Redirect the visitor on its first session visit, depending on its country. This feature can be disabled by store view scope, so the first redirect is only enabled on your main domain for example.

This feature can have non desirable behavior, for example for robots crawling your website. That's why you can set a list of user agents to ignore and to not process the redirection in this case. Moreover, a list of controller actions to ignore is also configurable.

Now you can select which visitor's country resolver to use, the available resolvers are:

  • Default Session Country (the country already set in session, or the default for the current store view).
  • CloudFare GEO-IP Country (use visitor'scountry available in the HTTP header value). CloudFare Country GEO-IP must be enabled, see more.

Any third party developers can add its own country resolver. Please read the developer section for further details.

Country to store mapping

Define the country to store relation. This configuration will allows Magento to redirect the visitor to the correct store view depending of the visitor's country. Multiple countries can be assigned to a single store view.

Settings

The configuration for this module is available in Stores > Configuration > General > Country Redirect.

Documentation

How to add a country resolver

Create a new final class and implement the following interface: Opengento\CountryStoreRedirect\Model\Country\ResolverInterface. The method public function getCountryCode(): string should returns the visitor's country code of origin. The country should be compliant to ISO 3166-1 alpha-2 format.

Register the new country resolver in the method factory, Vendor/Module/etc/di.xml:

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

If you want the resolver ba available in settings, register it in the resolver list 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>

The country resolver is ready to use.

SEO and Performance

We strongly discourage you to use the first visit redirect as it is considered harmful and bad practice. Instead show a dialog to allow the visitor to select the country of its preference.
This feature is available in our module Opengento_CountryStoreSwitcher opengento/module-country-store-switcher.

Support

Raise a new request to the issue tracker.

Authors

  • Opengento Community - Lead - Twitter Follow
  • Thomas Klein - Maintainer - GitHub followers
  • Contributors - Contributor - GitHub contributors

License

This project is licensed under the MIT License - see the LICENSE details.

That's all folks!

opengento/module-country-store-redirect 适用场景与选型建议

opengento/module-country-store-redirect 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.07k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2020 年 08 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「geoip」 「redirect」 「location」 「country」 「magento」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 opengento/module-country-store-redirect 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 opengento/module-country-store-redirect 我们能提供哪些服务?
定制开发 / 二次开发

基于 opengento/module-country-store-redirect 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 3

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-08-01