setono/sylius-geo-plugin 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

setono/sylius-geo-plugin

最新稳定版本:v1.0.0-alpha.7

Composer 安装命令:

composer require setono/sylius-geo-plugin

包简介

Setono example plugin for Sylius.

README 文档

README

Latest Version Software License Build Status Code Coverage

This plugin adds geo related functionality to your store. Right now it comes with these two features:

  • Redirect visitors based on their country
  • Output hreflang link tags with a Twig function to help search engines discover regional versions of your store

Installation

Step 1: Download the plugin

composer require setono/sylius-geo-plugin

Step 2: Enable the plugin

Then, enable the plugin by adding it to the list of registered plugins/bundles in config/bundles.php file of your project before (!) SyliusGridBundle:

<?php
$bundles = [
    Setono\SyliusGeoPlugin\SetonoSyliusGeoPlugin::class => ['all' => true],
    Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
];

Step 3: Configure plugin

# config/packages/setono_sylius_geo.yaml
imports:
    - { resource: "@SetonoSyliusGeoPlugin/Resources/config/app/config.yaml" }

Step 4: Import routing

# config/routes/setono_sylius_geo.yaml
setono_sylius_geo:
    resource: "@SetonoSyliusGeoPlugin/Resources/config/routes.yaml"

Step 5: Update your database schema

php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate

Step 6: Use an existing country code provider or create a new one

The plugin uses country code providers to provide the country code. The plugin comes with a single country code provider which is based on request headers. If you want to create your own provider, all you have to do is implement the CountryCodeProviderInterface. The service will be automatically tagged as setono_sylius_geo.country_code_provider.

NOTE: If you are using Cloudflare all you have to do is within your dashboard go to Rules > Transform Rules > Managed Transforms and enable the Add visitor location headers.

Usage

Redirect visitors based on their country

Go to https://your-store.com/admin/geo/rules/new to create a new rule. Here is an example:

Rule example

As you can see our goal is to redirect Danish visitors to our locale Danish store. We have excluded bots and our office IP so that bots can freely crawl our international store, and we are able to browse the international store without being redirected, although we are based in Denmark.

Output hreflang link tags

Add this twig code: {{ ssg_hreflang_tags() }} to your <head> section and it will output <link rel="alternate" hreflang="..." href="..."> tags.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-09