stefandoorn/sylius-seo-url-plugin 问题修复 & 功能扩展

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

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

stefandoorn/sylius-seo-url-plugin

最新稳定版本:v1.0.0

Composer 安装命令:

composer require stefandoorn/sylius-seo-url-plugin

包简介

SEO URLs for Sylius

README 文档

README

License Version Build Status

Features

  • Remove /taxons from taxon URLs

    1. Before: https://localhost/en_US/taxons/t-shirts
    2. After: https://localhost/en_US/t-shirts
  • Remove /products from product URLs

    1. Before: https://localhost/en_US/products/t-shirt-banana
    2. After: https://localhost/en_US/t-shirt-banana

Combined with disabling localised URLs, URLs can even be shorter.

Installation

  1. Require plugin with composer:

    composer require stefandoorn/sylius-seo-url-plugin
  2. Add plugin class to your AppKernel.

    $bundles = [
       new \StefanDoorn\SyliusSeoUrlPlugin\SyliusSeoUrlPlugin(),
    ];

    or to your bundles.php:

    return [
       // ...
       StefanDoorn\SyliusSeoUrlPlugin\SyliusSeoUrlPlugin::class => ['all' => true],
    ];
  3. Import routing (to override default shop routing):

    sylius_seo_url_shop:
        prefix: /{_locale}
        resource: "@SyliusSeoUrlPlugin/Resources/config/shop_routing.yml"

    Make sure it's imported after (because it overrides default Sylius routes):

    sylius_shop:
        resource: "@SyliusShopBundle/Resources/config/routing.yml"
        prefix: /{_locale}

    You can remove the prefix /{_locale} if you prefer url's without the prefix. In this case, the import looks like this:

        sylius_seo_url_shop:
            resource: "@SyliusSeoUrlPlugin/Resources/config/shop_routing.yml"
  4. Import configuration:

    - { resource: "@SyliusSeoUrlPlugin/Resources/config/config.yml" }
  5. Import repository method:

    The default findOneByChannelAndSlug for products is slow when used in a loop, therefore:

    1. Use the trait in your own Product Repository & add interface:

      use StefanDoorn\SyliusSeoUrlPlugin\Repository\ProductExistsByChannelAndSlug;
      use StefanDoorn\SyliusSeoUrlPlugin\Repository\ProductExistsByChannelAndSlugAwareInterface;
      use Sylius\Bundle\CoreBundle\Doctrine\ORM\ProductRepository as BaseProductRepository;
      
      final class ProductRepository extends BaseProductRepository implements ProductExistsByChannelAndSlugAwareInterface
      {
          use ProductExistsByChannelAndSlug;
      }
    2. Or use the Product repository as provided, add to your config:

      sylius_product:
          resources:
              product:
                  classes:
                      repository: StefanDoorn\SyliusSeoUrlPlugin\Repository\ProductRepository

统计信息

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

GitHub 信息

  • Stars: 21
  • Watchers: 2
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-12-03