stefandoorn / sylius-seo-url-plugin
SEO URLs for Sylius
Installs: 73 385
Dependents: 0
Suggesters: 0
Security: 0
Stars: 21
Watchers: 3
Forks: 10
Open Issues: 5
Type:sylius-plugin
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-12-13 12:47:59 UTC
README
Features
-
Remove
/taxons
from taxon URLs- Before:
https://localhost/en_US/taxons/t-shirts
- After:
https://localhost/en_US/t-shirts
- Before:
-
Remove
/products
from product URLs- Before:
https://localhost/en_US/products/t-shirt-banana
- After:
https://localhost/en_US/t-shirt-banana
- Before:
Combined with disabling localised URLs, URLs can even be shorter.
Installation
-
Require plugin with composer:
composer require stefandoorn/sylius-seo-url-plugin
-
Add plugin class to your
AppKernel
.$bundles = [ new \StefanDoorn\SyliusSeoUrlPlugin\SyliusSeoUrlPlugin(), ];
or to your
bundles.php
:return [ // ... StefanDoorn\SyliusSeoUrlPlugin\SyliusSeoUrlPlugin::class => ['all' => true], ];
-
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"
-
Import configuration:
- { resource: "@SyliusSeoUrlPlugin/Resources/config/config.yml" }
-
Import repository method:
The default
findOneByChannelAndSlug
for products is slow when used in a loop, therefore:-
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; }
-
Or use the Product repository as provided, add to your config:
sylius_product: resources: product: classes: repository: StefanDoorn\SyliusSeoUrlPlugin\Repository\ProductRepository
-