How to change URL's used by sitemap.xml

Right now, sitemap as I can see uses all links from the shop. Is there a way to set that sitemap only uses some of the links. For example, only categories. No articles etc. Just categories?

Thank you

**public static function** getSubscribedEvents() { **return** [_// xml_ **'Shopware\_Controllers\_Frontend\_SitemapXml::indexAction::after'** =\> **'onAfterSitemapContent'** , **'Shopware\_Controllers\_Frontend\_SitemapMobileXml::indexAction::after'** =\> **'onAfterSitemapContent'** , _// frontend_ **'Shopware\_Modules\_Sitemap\_indexAction'** =\> **'onSitemapIndexAction'** ,]; }

**public function** onSitemapIndexAction(\Enlight\_Event\_EventArgs $arguments) { $sitemap = $arguments-\>getReturn(); var\_dump($sitemap); // there you can see all links **unset** ($sitemap[1]); // for example there we will delete manufacturers link $arguments-\>setReturn($sitemap); **return** $arguments-\>getReturn(); }

 

 

 

@odessite schrieb:

public static function getSubscribedEvents() { return [// xml ‚Shopware_Controllers_Frontend_SitemapXml::indexAction::after‘ => ‚onAfterSitemapContent‘ , ‚Shopware_Controllers_Frontend_SitemapMobileXml::indexAction::after‘ => ‚onAfterSitemapContent‘ , // frontend ‚Shopware_Modules_Sitemap_indexAction‘ => ‚onSitemapIndexAction‘ ,]; }

public function onSitemapIndexAction(\Enlight_Event_EventArgs $arguments) { $sitemap = $arguments->getReturn(); var_dump($sitemap); // there you can see all links unset ($sitemap[1]); // for example there we will delete manufacturers link $arguments->setReturn($sitemap); return $arguments->getReturn(); }

 I am not sure how this will effect url’s under sitemap.xml file?  Since this is just a front controller, and url’s are generated with command sw:generate:sitemap

I ended up creating plugin, and adding my own services for SitemapExporter

 

I see, my comment related shopware till version 5.5

Great that you found solution by yourself!