PrestaShop Developer Conference
PrestaShop Developer Conference
Paris, France - November 30, 2023
Let's talk code, commerce and open source.

Hook actionModifyFrontendSitemap 8.1

Information

Allows modules to add own urls (even whole new groups) to frontend sitemap:

For example landing pages, blog posts and others.

Hook locations:

  • front office

Hook type: action

Located in:

Call of the Hook in the origin file

Hook::exec(
    'actionModifyFrontendSitemap',
    ['urls' => &$sitemapUrls],
    null,
    false,
    true,
    false,
    null,
    true
);

Example implementation

public function hookActionModifyFrontendSitemap($params)
{
    $customUrls = [
        [
            'id' => 'custom-url-1',
            'label' => 'Custom URL',
            'url' => 'https://prestashop-project.org',
        ]
    ];

    $params['urls']['pages']['links'] = array_merge($params['urls']['pages']['links'], $customUrls); // add custom urls to pages group
    unset($params['urls']['categories']); // hide categories
}