How to Include Custom Sitemap.xml in Robots.txt File in Prestashop

How to Include Custom Sitemap.xml in Robots.txt File in Prestashop

The function AdminMetaController::generateRobotsFile() is responsible for generating the robots.txt file in Prestashop. This function is executed via PREFERENCES -> SEO & URLS -> Generate robots.txt file.

But in one of our projects we faced the following issue: the sitemap.xml file is generated by the default Gsitemap module, which saves the file under the name  {shop_id}_index_sitemap.xml. But the function AdminMetaController::generateRobotsFile() uses the following code to find sitemap:

This means that the function is checking exactly for the file with the name sitemap.xml and includes it into robots.txt. But our file has a different name (1_index_sitemap.xml), that is why search engines are not able to find it.

To fix this, we created override/controllers/admin/AdminMetaController.php of the function generateRobotsFile():

This way Prestashop will be able to find and work with the sitemap file.

For Prestashop SEO module please check this page: http://module-presta.com/seo-search-engine-optimization.html



6 comments

  1. Hi,

    I’m not sure, but is this bug present in all major PS releases including 1.6?

    We have our store still on 1.5.4.1 so I wonder if I should apply this fix?

  2. Dean Dolić,

    I saw this bug only in Prestashop 1.6, but if you have similar problems in other versions you can try this method.

  3. Hi Alex,

    Thanks for the post. Very usefull.
    Honestly, i don’t understand at all how can Prestashop have this kind of errors.

  4. I cannot find AdminMetaController.php under override/controllers/admin. In the folder admin only got index.php and templates. What should i do? My google webmaster tool only show 1 index page. How i can solve this?

Post a new comment

top
BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *