Live Demo: Try this and other plugins live — no installation, no risk: demo.markus-michalski.net
There are three ways to generate sitemaps. All three use the same generator and write the same files.
| Admin button | Scheduled task | Console command | |
|---|---|---|---|
| Sales Channels | the one selected in the configuration | all active storefront Sales Channels for which scheduled generation is on | all active storefront Sales Channels or one via -s |
| Content types | all enabled | all enabled | all enabled, restrictable via -t |
| Delete old files | always | always | only with -c / --clear |
In the plugin configuration (Extensions > My Extensions > Advanced XML Sitemap) the Manual Generation card shows, for the Sales Channel selected at the top, the number of URLs in total and per type (products, categories, CMS pages, manufacturers).
The numbers shown are approximations from the database: they take neither the Exclude empty categories filter nor the separation of categories and CMS pages nor missing SEO URLs into account. The actual number is shown in the result after generation.
The button uses the Admin API, see Admin API.
The task mmd.sitemap.generation runs at the configured interval (default: daily) and generates all enabled types for every active storefront Sales Channel. Existing sitemap*.xml files in the target directory of the respective Sales Channel are deleted first. If one Sales Channel fails, the task writes an error to the log and continues with the next.
Settings and prerequisites are described under Configuration and Installation.
bin/console mmd:sitemap:generate
| Option | Description |
|---|---|
-s, --sales-channel |
Generate only for this Sales Channel ID. Without it, all active storefront Sales Channels are processed |
-t, --type |
Generate only these types: products, categories, cms, manufacturers. Can be repeated |
-c, --clear |
Delete existing sitemap*.xml files in the target directory before generation |
--dry-run |
Write nothing, only show the URL count per enabled type |
Types that are switched off in the Sales Channel's configuration are not generated even with -t. Unknown values for -t are ignored. If no type remains, the command reports that no sitemap type is enabled for the Sales Channel.
With --dry-run the command lists the URL counts of all enabled types of the Sales Channel, regardless of -t. These are the same approximations as in the Admin.
# Generate only the products sitemap
bin/console mmd:sitemap:generate -t products
# Delete old sitemaps and regenerate
bin/console mmd:sitemap:generate --clear
# Multiple types
bin/console mmd:sitemap:generate -t products -t categories
# Only for a specific Sales Channel
bin/console mmd:sitemap:generate -s 019b7dfcab75700fada02799328e8440
# Only count, write nothing
bin/console mmd:sitemap:generate --dry-run
For each Sales Channel the command prints the effective configuration, the output path and the files written. It exits with an error code only if no active Sales Channel was found. The switch for scheduled generation has no influence on the command.
If you do not want to use the Shopware scheduler, switch off Enable automatic generation and generate the sitemaps with a cron job:
# Daily at 3 AM
0 3 * * * cd /var/www/shopware && bin/console mmd:sitemap:generate --clear
If the task and the cron job run at the same time, the sitemap is generated twice. Use only one of the two ways.