Google Sitemap generation in Magento 1.4.1.1
I have found that in addition to the administrative settings, a few modifications are required to the sitemap config.xml file in order to have the sitemap automatically generated using cron. Magento’s main cron job kicks off the sitemap cron job, so you’ll first need to setup the execution of the cron.php file (or cron.sh).
On HostGator, Magento’s main cron job can be scheduled through the cpanel with this command:
/usr/local/bin/php /home/myaccount/public_html/cron.php
You may have to adjust the path to php on your server. Also replace the path to cron.php with the path to this file on your server. The full command to run the cron job at minute 15 of every hour is
15 * * * * /usr/local/bin/php /home/myaccount/public_html/cron.php
To create your initial Google Sitemap, login to your Magento Admin and go to Catalog > Google Sitemap. If a sitemap does not already exist, click “Add Sitemap”. Enter the name of the file to create (typically sitemap.xml) and the path to the file. Note that if you want the sitemap in your root folder, you may have to adjust permissions first to let the file be created there (then change them back for security’s sake). Alternatively, create a blank sitemap.xml first, and then let Magento update it. You can also choose to put the sitemap into a subdirectory. Click Save and Generate to save your settings and generate your first sitemap.
Now for the scheduling. Go to System > Configuration and click the Google Sitemap in the Catalog section. Under Generation Settings, set Enabled to Yes.
The last step is to edit the config.xml file for the Sitemap. This is under app/code/core/Mage/Sitemap/etc/config.xml. Open this file and find the section starting with <crontab>. Replace this section with the following:
<crontab> <jobs> <sitemap_generate> <schedule><cron_expr>0 2 * * *</cron_expr></schedule> <run><model>sitemap/observer::scheduledGenerateSitemaps</model></run> </sitemap_generate> </jobs> </crontab>
This tells the system to add the sitemap to the crontab and generate the sitemap at 2am every day. Also check the section of the file with <enabled>. Make sure enabled is set to 1, as shown below:
<generate> <enabled>1</enabled> <error_email><![CDATA[]]></error_email> <error_email_template>sitemap_generate_error_email_template</error_email_template> <error_email_identity>general</error_email_identity> </generate>





Leave a comment