stefandoorn / sitemap-plugin

Sitemap Plugin for Sylius eCommerce platform
MIT License
79 stars 44 forks source link
ecommerce php sitemap sitemap-generator sitemap-plugin sylius symfony

Sylius Sitemap Plugin

License Version Build Coverage Status

Big thanks

Goes out to the Sylius team. The core code of this plugin is created by the Sylius team. Unfortunately it got removed from the Sylius core. Luckily the Sylius team approved the extraction to a separate bundle.

Features

Installation

  1. Run composer require stefandoorn/sitemap-plugin.
  2. Add to app/config/bundles.php:
  SitemapPlugin\SitemapPlugin::class => ['all' => true],
  1. Add to app/config/packages/_sylius.yaml:
    - { resource: "@SitemapPlugin/Resources/config/config.yaml" }
  1. Add to app/config/routes.yaml:
sylius_sitemap:
    resource: "@SitemapPlugin/Resources/config/routing.yml"
  1. Add to app/config/packages/sylius_sitemap.yaml:

  2. Forcing HTTPS on Generated URLs, see Symfony Docu. In console commands, where there is no HTTP request, URLs use http by default. You can change this globally with these configuration parameters:

# config/services.yaml
parameters:
    router.request_context.scheme: 'https'

Usage

Generate your sitemap from the CLI:

 $ bin/console sylius:sitemap:generate

Add this command to your cronjob to regularly generate a new sitemap, e.g. once a day.

If you only want to generate the sitemap for a specific channel, use:

 $ bin/console sylius:sitemap:generate --channel=US_WEB

The plugin defines three default URI's:

Next to this, each provider registeres it's own URI. Take a look in the sitemap index file for the correct URI's.

Default Configuration

Get a full list of configuration: bin/console config:dump-reference sitemap

sitemap:
    providers:
        products: true
        taxons: true
        static: true
    template:             '@SitemapPlugin/show.xml.twig'
    index_template:       '@SitemapPlugin/index.xml.twig'
    exclude_taxon_root:   true
    hreflang:             true
    images:               true
    static_routes:
        - { route: sylius_shop_homepage, parameters: [], locales: [] }
        - { route: sylius_shop_contact_request, parameters: [], locales: [] }

The request context is also important for generating the URLs inside the sitemap:

Default storage

By default the sitemaps will be saved in %kernel.root_dir%/var/sitemap. You can change this setting by adjusting the parameter sylius.sitemap.path.

Feature switches

Default providers

Add own provider