项目作者: stefandoorn

项目描述 :
Sitemap Plugin for Sylius eCommerce platform
高级语言: PHP
项目地址: git://github.com/stefandoorn/sitemap-plugin.git
创建时间: 2017-03-21T15:40:18Z
项目社区:https://github.com/stefandoorn/sitemap-plugin

开源协议:MIT License

下载


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

  • Creates a sitemap index file to point to sub sitemap files per type of data
  • Default providers: taxons, products & static content (homepage & contact)
  • Easily add your own providers
  • Product provider supports locales (hreflang) & is channel aware
  • Taxon provider supports locales (hreflang)

Installation

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

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

Usage

Generate your sitemap from the CLI:

  1. $ 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:

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

The plugin defines three default URI’s:

  • sitemap.xml: redirects to sitemap_index.xml
  • sitemap_index.xml: renders the sitemap index file (with links to the provider xml files)

Next to this, each provider registers its 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

  1. sitemap:
  2. providers:
  3. products: true
  4. taxons: true
  5. static: true
  6. template: '@SitemapPlugin/show.xml.twig'
  7. index_template: '@SitemapPlugin/index.xml.twig'
  8. exclude_taxon_root: true
  9. hreflang: true
  10. images: true
  11. static_routes:
  12. - { route: sylius_shop_homepage, parameters: [], locales: [] }
  13. - { route: sylius_shop_contact_request, parameters: [], locales: [] }

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

  • The hostname is defined per channel, if nothing set it defaults to localhost
  • Other request context settings can be adjusted as mentioned in the Symfony docs

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

  • Products
  • Taxons
  • Static content (homepage & contact)

Add own provider

  • Register & tag your provider service with sylius.sitemap_provider
  • Let your provider implement UrlProviderInterface
  • Use one of the default providers as an example to implement code