Magento 1: XML Sitemap Setup – Fixing Errors

I had an issue in Magento getting an XML sitemap to generate.  This site was launched a site about 6 months ago, and now went through a rather massive redesign and is being relaunched.  URL changes, etc. are all at play here.  This is under a Magento install that has multiple stores in it.

Confusion About Configuration

An XML sitemap was created upon initial launch, however hasn’t been updated since.  I’m not sure of a few things though – both how the sitemap got generated to begin with and how it never regenerated after that.  The reason for my confusion is that the sitemap was never defined in the Magento Admin.

Error Message from Magento

But to make things “worse”, when I went to setup this sitemap in the Magento Admin (Catalog -> Google Sitemap -> Add Sitemap), I received the following error message: 

Error message from Magento when Setting up Sitemap
I received this error message when trying to setup an XML sitemap in Magento.

Now in fairness, this path/file already existed.  So I tried a different file name but got the same error message.  My guess of what is happening here is there is a file permissions issue happening?  I’m not 100% sure though.

Fixing the Problem

Where there’s a will there’s a way, right?  As with many operations that seem to fail in Magento, it’s time to just go right to the database.  The data for this feature of Magento is found in the sitemap table.  Simply fill in the following fields – all others can be left null:

  • sitemap_filename
    • Filename of the sitemap file you wish to create
  • sitemap_path
    • The path that you want the sitemap file to be saved to.  Use “/” for the root directory.
  • store_id
    • The numeric store ID for the store you wish to have the sitemap generated for.

Save this data to the database, then go back to the Magento Admin to Catalog -> Google Sitemap.  You should see your new sitemap display on the list.  Click the Generate link and Magento should do the rest of the hard work from here.  Likewise the CRON job that refreshes the sitemaps from here on forward should now work.

One potential other issue that you might run into on this final step is that I’m not 100% sure if Magento will create the file successfully at this time or not.  In my case the file was already there and I didn’t take the time to test if it would generate a file if it didn’t exist.

Also of note – my file permissions for this XML sitemap file are set to 666 (RW- RW- RW-).