stefandoorn / sylius-seo-url-plugin
Sylius 的 SEO URL
v1.0.0
2021-12-12 09:34 UTC
Requires
- php: ^7.2 || ^8.0
- sylius/sylius: ^1.3
Requires (Dev)
- behat/behat: ^3.4
- behat/mink: ^1.7@dev
- behat/mink-browserkit-driver: ^1.3
- behat/mink-extension: ^2.2
- behat/mink-selenium2-driver: ^1.3
- friends-of-behat/context-service-extension: ^1.2
- friends-of-behat/cross-container-extension: ^1.1
- friends-of-behat/page-object-extension: ^0.2.1
- friends-of-behat/service-container-extension: ^1.0
- friends-of-behat/symfony-extension: ^1.2.1
- friends-of-behat/variadic-extension: ^1.1
- lakion/mink-debug-extension: ^1.2.3
- phpspec/phpspec: ^5.0
- phpstan/phpstan-doctrine: ^0.10
- phpstan/phpstan-shim: ^0.10
- phpstan/phpstan-symfony: ^0.10
- phpstan/phpstan-webmozart-assert: ^0.10
- phpunit/phpunit: ^6.5
- sensiolabs/security-checker: ^5.0
- sylius-labs/coding-standard: ^2.0
- symfony/browser-kit: ^3.4|^4.1
- symfony/debug-bundle: ^3.4|^4.1
- symfony/dotenv: ^3.4|^4.1
- symfony/intl: ^3.4|^4.1
- symfony/web-profiler-bundle: ^3.4|^4.1
- symfony/web-server-bundle: ^3.4|^4.1
Conflicts
- symfony/browser-kit: 4.1.8
- symfony/dependency-injection: 4.1.8
- symfony/dom-crawler: 4.1.8
- symfony/routing: 4.1.8
- symfony/symfony: 4.1.8
This package is auto-updated.
Last update: 2024-09-13 12:16:00 UTC
README
功能
-
从类目 URL 中移除
/taxons
- 之前:
https://localhost/en_US/taxons/t-shirts
- 之后:
https://localhost/en_US/t-shirts
- 之前:
-
从产品 URL 中移除
/products
- 之前:
https://localhost/en_US/products/t-shirt-banana
- 之后:
https://localhost/en_US/t-shirt-banana
- 之前:
结合 禁用本地化 URL,URL 可以更短。
安装
-
使用 composer 安装插件
composer require stefandoorn/sylius-seo-url-plugin
-
将插件类添加到您的
AppKernel
。$bundles = [ new \StefanDoorn\SyliusSeoUrlPlugin\SyliusSeoUrlPlugin(), ];
或添加到您的
bundles.php
return [ // ... StefanDoorn\SyliusSeoUrlPlugin\SyliusSeoUrlPlugin::class => ['all' => true], ];
-
导入路由(覆盖默认商店路由)
sylius_seo_url_shop: prefix: /{_locale} resource: "@SyliusSeoUrlPlugin/Resources/config/shop_routing.yml"
确保它在(因为它覆盖了默认 Sylius 路由)之后导入
sylius_shop: resource: "@SyliusShopBundle/Resources/config/routing.yml" prefix: /{_locale}
如果您更喜欢不带前缀的 URL,可以删除前缀
/{_locale}
。在这种情况下,导入看起来像这样sylius_seo_url_shop: resource: "@SyliusSeoUrlPlugin/Resources/config/shop_routing.yml"
-
导入配置
- { resource: "@SyliusSeoUrlPlugin/Resources/config/config.yml" }
-
导入仓库方法
当在循环中使用时,默认的
findOneByChannelAndSlug
对产品是慢的,因此-
在您的 Product Repository 中使用特性并添加接口
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; }
-
或者使用提供的 Product repository,添加到您的配置中
sylius_product: resources: product: classes: repository: StefanDoorn\SyliusSeoUrlPlugin\Repository\ProductRepository
-