infrangible / m2-sitemap
Generates XML sitemaps for products (with images), categories and CMS pages per store view, on a schedule or on demand, with exclusion options and large-catalog splitting.
Package info
github.com/infrangible-dev/m2-sitemap
Type:magento2-module
pkg:composer/infrangible/m2-sitemap
Requires
- php: >=8.1
- fewedev/base: ~2.4.1
- infrangible/m2-backend-widget: ~4.0.4
- infrangible/m2-core: ~5.0.4
- infrangible/m2-foundation: ~3.0.1
- infrangible/m2-simple-mail: ~2.0.0
- infrangible/m2-task: ~3.0.0
- magento/framework: ~103.0.6
- magento/module-backend: ~102.0.0
- magento/module-catalog: ~104.0.0
- magento/module-cms: ~104.0.0
- magento/module-config: ~101.2.0
- magento/module-eav: ~102.1.0
- magento/module-store: ~101.1.0
- magento/module-ui: ~101.2.0
- psr/log: ~2.0.0||~3.0.0
Requires (Dev)
- infrangible/phpstan-magento: ~1.2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Generates XML sitemaps of the products (with their images), categories and CMS pages of every store, as task of Infrangible Task: every night by cron, from the admin or on the console. An alternative to the sitemap of Magento.
Sitemaps
- Every store has a file (Stores > Configuration > Infrangible Solutions > Sitemap > General > File Name, relative to
the document root, for example
sitemap.xmlorsitemap/de.xml); stores with the same file share it. - If the stores have several files,
sitemap.xmlbecomes the index of their files ("Generate Main Sitemap"); no store may then usesitemap.xmlitself. - A file with more than 50,000 URLs is split into numbered files (
sitemap_001.xml, ...), and the file becomes their index. - Every URL is written once. URLs use the base URL of their store, with HTTPS if the store uses it in the frontend, also when the sitemap is generated by cron or on the console.
Sources
| Source | Content |
|---|---|
| Product | visible, enabled products of the website, in stock unless out of stock products are shown; with their images and the first image as thumbnail of the PageMap |
| Category | active categories |
| CMS | active CMS pages; the home page of the store with its base URL and priority 1.0, without the 404 page |
- Each source can be switched off, with its own change frequency and priority (from 0.0 to 1.0), per store.
- Products, categories and CMS pages have the attribute "Exclude from Sitemap".
- Other modules add sources in their
config.xml:infrangible_sitemap/source/<name>is the name of a class that implementsInfrangible\Sitemap\Model\Source\ISource(getStoreData()andtransformStoreData(), which returnsInfrangible\Sitemap\Model\ISitemapUrlobjects fromInfrangible\Sitemap\Model\SitemapUrlFactory).Infrangible\Sitemap\Helper\Dataprovides URLs, dates, change frequency and priority like the sources of this module.
Events:
| Event | Data |
|---|---|
infrangible_sitemap_attributes_product |
attributes: attribute codes to load |
infrangible_sitemap_attributes_category |
attributes: attribute codes to load |
infrangible_sitemap_transform_product |
sitemap_url, product_data |
infrangible_sitemap_transform_category |
sitemap_url, category_data |
infrangible_sitemap_transform_cms |
sitemap_url, cms_page |
Generating
- Cron: the job
task_sitemapruns at 4:10; Stores > Configuration > Tasks > Sitemap > Execution changes the cron expression. - Admin: Infrangible Solutions > Sitemap > Manage lists the files with their stores, date and link; "Generate" generates a file, "Generate All" all files. Admin users need the resource "Sitemap" and the resource of Infrangible Task.
- Console:
bin/magento task:sitemap(options of Infrangible Task, for example--store_code=default).
The task logs every run and sends summaries like every task of Infrangible Task.
Magento's own sitemap (Marketing > SEO & Search > Site Map) writes sitemap.xml as well; do not let both write the
same file.
Requirements
- Magento Open Source or Adobe Commerce 2.4.6 or newer
- PHP 8.1 or newer
Installation
composer require infrangible/m2-sitemap bin/magento module:enable Infrangible_Sitemap bin/magento setup:upgrade
In production mode, also run bin/magento setup:di:compile and bin/magento setup:static-content:deploy.
License
Infrangible Sitemap is licensed under the MIT License - see the LICENSE file for details.