Fixed version of the gsitemap module

Creative Commons Licence

There seems to have been a lot of problems with the Google XML Sitemap generator shipping with PrestaShop 1.2, so I’ve had a run through and re-written a fair bit of the code to fix these issues.

The main changes (in 1.4.2) are:

  • New XML generation code using the DOMDocument(*) class
  • Modified the logic to remove extra elements from the generated URLs
  • Added an xml-stylesheet reference to the output file, xsl included in download
  • Fixed the issues when “Friendly” urls are turned off
  • Add a new field to the cms table on install to track modified dates (auto updating)
  • Added removal of additional field on uninstall

(*)If your server doesn’t support this then sorry. Go elsewhere for hosting!

Updated to 1.4.3 — 10 August 2009

  • Added error checking and reporting

Updated to 1.4.4 — 18 August 2009

  • Added images to the sitemap (as introduced in the 1.4 version in the distribution)
  • including fixes to the Link class which broke 1.4.3, so fixed that
  • Added cross-compatibility so this version works in both 1.2.0.x and 1.2.1.x
  • Fixed a bug when __PS_BASE_DIR__ is set to other than the site root

Example output: with friendly urls and without friendly urls.

Download the Prestashop Google XML Sitemap Module v1.4.4 now.

Sharing is caring!

Posted on August 9, 2009 | Related Categories: Free Prestashop Modules, Prestashop | 12 comments

  • Jonathan

    Just wondering, are you aware of any errors with www being used vs non www? We are using v1.1.0.5 and see this error. Error loading stylesheet: An unknown error has occurred (805303f4) when www is used, no error when non www is used.

  • Ferhat

    i got error on gsitemap modules

    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2020520 bytes) in /home/prestcom/public_html/modules/gsitemap/gsitemap.php on line 226

    What can i do ?
    Can you help me pls?

  • Carl Nelson

    By the way, even with 1.2 installed, the image links do not match those used by the auto-generated .htaccess in the latest version of Prestashop. You can see your own xml links for an example.

  • Carl Nelson

    Does this not work at all for 1.1? I am using module version 1.3 with success, but I would like to use the new features. But I get the following errors when I try to generate a sitemap:

    Invalid argument supplied for foreach() in gsitemap.php on line 106

    Call to undefined method Link::getImageLink() in gsitemap.php on line 219

  • Ovidiu

    Error loading stylesheet: An XSLT stylesheet does not have an XML mimetype:

    please help.

  • Mary Luketich

    Hung Bui: Please identify the file where you made the code changes. My images are gone, but they are there in the backoffice.

    Thank you.

  • Hung Bui

    Just spotted an issue with the images.. all links are broken.

    At line 219

    replace this code :

    $tmpLink = ‘http://’.htmlspecialchars($_SERVER[‘HTTP_HOST’], ENT_COMPAT, ‘UTF-8′).$link->getImageLink(Tools::link_rewrite($image[‘legend’]), $image[‘id_product’].’-‘.$image[‘id_image’]);


    $tmpLink = ‘http://’.htmlspecialchars($_SERVER[‘HTTP_HOST’], ENT_COMPAT, ‘UTF-8′).$link->getImageLink(Tools::link_rewrite($image[‘legend’]), $image[‘id_product’].’-‘.$image[‘id_image’],’thickbox’);

    the ‘thinkbox’ is missing for function getImageLink().


  • Atwill

    Alas, your sitemap generator is no more working under PS 1.2.5 (at least for me).
    When clicking on the generation button, the next page only displays the navigation stuff (w/o anything else).

  • Hung Bui

    Thanks Paul. I love the way you use style for XML file.. it is readable for human and also crawler (robots).

    All the bests.

  • Mozack


    I’m having troubles with the module. I saw your example and it have errors too.

    At the end of sitemap, the links generated for images are wrong. Google webmaster tools is giving errors in that part of code.

    How can we resolve this problem?

  • Cb

    This works beautifully Paul, many thanks! However, there is a problem with the url rewriting. I changed the category url rewriting rules to make them “” instead of the ugly “”, and when i make the site map, the category lines come out as “3-category”, even though the products come out as “”, the “3-category” links are broken because they don’t exist, so i can’t submit them to google! i can manually edit the sitemap.xml, but there is obviously a deeper problem somewhere, that’s still reading the categories with the old url rewriting rules that i deleted!

    can you give me any advice in any way? thank you very much in advance if you can/know

  • Ken

    Thank you Paul.