![]() |
free google sitemap
I was looking for a module that creates a sitemap for Google. I found one for free at xcartmod.com .
It is a nice mod but it has some downsides: 1. It looks the db and creates the urls the following way: www.site.com//product.php?productid=xx which is bad when you use clean urls. 2. Doesn't include the manufacturer urls So I made some modifications to fix the above mentioned problems and, since it is a free module, I thought I could post the modifications so someone else can use them. If for any reason you think that is wrong, please tell me and I will remove everything from this post. So I opened the ../modules/xCartMod_Google_Sitemap/sitemap_xml.php and made the following changes: 1. Replaced Code:
$cats = func_query("SELECT * FROM $sql_tbl[categories] WHERE avail='Y'"); Code:
$cats = func_query("SELECT * FROM $sql_tbl[categories], $sql_tbl[clean_urls] WHERE resource_type = 'C' AND categoryid = resource_id AND avail = 'Y'"); 2. Replaced Code:
$prods = func_query("SELECT * FROM $sql_tbl[products] WHERE forsale='Y'"); Code:
$prods = func_query("SELECT * FROM $sql_tbl[products], $sql_tbl[clean_urls] WHERE resource_type = 'P' AND productid = resource_id AND forsale = 'Y'"); 3. Replaced Code:
$pages = func_query("SELECT * FROM $sql_tbl[pages] WHERE active='Y'"); Code:
$pages = func_query("SELECT * FROM $sql_tbl[pages], $sql_tbl[clean_urls] WHERE resource_type = 'S' AND pageid = resource_id AND active = 'Y'"); 4. Added Code:
$manufacturers = func_query("SELECT * FROM $sql_tbl[manufacturers], $sql_tbl[clean_urls] WHERE resource_type = 'M' AND manufacturerid = resource_id AND avail = 'Y'"); Code:
$xml .= '<url> You are ready! Your sitemap.xml contains your products,categories, manufacturer and static pages clean urls. It is updated once a day (if you visit the admin side of your shop) and is stored in www.yoursite.com/sitemap.xml . I made the changes on my 4.3.0 test installation (I'm now on 4.2.3 and want to upgrade to 4.3.0) and seems to work perfectly. It will work and on previous versions if the database tables maintain the same structure with 4.3.0. Please test before you do anything on your live shop!!! Best regards, Andreas |
Re: free google sitemap
thanks for mentioning this.
i modified it like you said without the last manufacturer part. is it supposed to show the clean url after? mine is still showing the ~productid=xx |
Re: free google sitemap
Quote:
The module runs each time you load a page in the admin part of your site. The module also creates two entries in the "config" table of your database. In one of them "xcartmod_sitemap_time", it saves the current date. Since we need our sitemap created only once in a day there is an if statement inside it. Before creating the sitemap, it checks if the current date is the same with the one in "xcartmod_sitemap_time". If it isn't, it creates a new sitemap and writes the current date to the db. If it is, it does nothing. So you have created your sitemap but you can't create another one before the day passes. Just delete the value in "xcartmod_sitemap_time" entry in the "config" table. If you don't want (for testing purposes) to update the date entry and check the date in the db then replace: Code:
$xm_today = mktime(0, 0, 0, date("m"), date("d"), date("Y")); Code:
//$xm_today = mktime(0, 0, 0, date("m"), date("d"), date("Y")); Andreas Nikolaidis |
Re: free google sitemap
You are a gentleman, sir. Thank you for posting.
|
Re: free google sitemap
You are welcome :)
Andreas Nikolaidis |
Re: free google sitemap
1 Attachment(s)
Works great on 4.2.
You just need to make sure you have a sitemap.xml with urlset headers and the file is set to chmod 666 in your public_html folder. I've attached one for any novices. |
Re: free google sitemap
Quote:
I found that I had to set mine to 777 in order for the script to be able to write the XML data. Darren |
Re: free google sitemap
Woooh this modification is great thank you very much, it works perfectly in 4.2.3.
Just one question, i want to add an extra condition to the product query because if the main category of the product is not available I don't want the products to appear in the sitemap but i don't know how to made the JOIN to the category table in the query. Can you help me? $prods = func_query("SELECT * FROM $sql_tbl[products], $sql_tbl[clean_urls] WHERE resource_type = 'P' AND productid = resource_id AND forsale = 'Y'"); if (is_array($prods[0])) foreach($prods as $pr) { $xml .= '<url> <loc>'.$http_location.'/'.$pr["clean_url"].'.html</loc> <lastmod>'.$today.'</lastmod> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>'; } |
Re: free google sitemap
For that extra condition to work we need to search two extra tables in the database.
Try to replace Code:
$prods = func_query("SELECT * FROM $sql_tbl[products], $sql_tbl[clean_urls] WHERE resource_type = 'P' AND productid = resource_id AND forsale = 'Y'"); with Code:
$prods = func_query("SELECT * FROM $sql_tbl[xcart_clean_urls], $sql_tbl[xcart_products_categories], $sql_tbl[xcart_products], $sql_tbl[xcart_categories] WHERE xcart_clean_urls.resource_type = 'P' AND xcart_products.productid = xcart_clean_urls.resource_id AND main = 'Y' AND xcart_products.productid = xcart_products_categories.productid AND xcart_products.forsale = "Y" AND xcart_products_categories.categoryid = xcart_categories.categoryid AND xcart_categories.avail = 'Y'"); I hope this works for you. Please check carefully to see if the result is correct. Andreas |
Re: free google sitemap
Quote:
Hi Andreas, thank you very much, I have tried the folowing: Code:
$prods = func_query("SELECT * FROM $sql_tbl[xcart_clean_urls], $sql_tbl[xcart_products_categories], $sql_tbl[xcart_products], $sql_tbl[xcart_categories] WHERE xcart_clean_urls.resource_type = 'P' AND xcart_products.productid = xcart_clean_urls.resource_id AND xcart_products_categories.main = 'Y' AND xcart_products.productid = xcart_products_categories.productid AND xcart_products.forsale = 'Y' AND xcart_products_categories.categoryid = xcart_categories.categoryid AND xcart_categories.avail = 'Y'"); that is the same as you wrote but changing Code:
AND main = 'Y' Code:
AND xcart_products_categories.main = 'Y' I get the following error: INVALID SQL: 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' , , WHERE xcart_clean_urls.resource_type = 'P' AND xcart_products.productid = ' at line 1 SQL QUERY FAILURE:SELECT * FROM , , , WHERE xcart_clean_urls.resource_type = 'P' AND xcart_products.productid = xcart_clean_urls.resource_id AND xcart_products_categories.main = 'Y' AND xcart_products.productid = xcart_products_categories.productid AND xcart_products.forsale = 'Y' AND xcart_products_categories.categoryid = xcart_categories.categoryid AND xcart_categories.avail = 'Y' don't know what happens... |
Re: free google sitemap
My mistake. I used wrong variables for the table names. The
Code:
AND main = 'Y' So, try this: Code:
$prods = func_query("SELECT * FROM $sql_tbl[clean_urls], $sql_tbl[products_categories], $sql_tbl[products], $sql_tbl[categories] WHERE xcart_clean_urls.resource_type = 'P' AND xcart_products.productid = xcart_clean_urls.resource_id AND main = 'Y' AND xcart_products.productid = xcart_products_categories.productid AND xcart_products.forsale = 'Y' AND xcart_products_categories.categoryid = xcart_categories.categoryid AND xcart_categories.avail = 'Y'"); This must be correct. Andreas |
Re: free google sitemap
Thanks man that worked! :)
Anyway I have find a "bug": If you don't use ".html" in your pages and products urls you have to remove the "html" from the code so the lines are finally like this: Code:
<loc>'.$http_location.'/'.$pr["clean_url"].'</loc> Yours! |
Re: free google sitemap
Hello,
Im creator of this module. Here version for xcart 4.3.x with supporting "clean_url" option. Enjoy ;) UPDATE: This is old version of module. New version on post #24 - http://forum.x-cart.com/showpost.php?p=296734&postcount=24 |
Re: free google sitemap
Thanks
I have tried IronShop_Google_Sitemap this on my www.qualitechnic.co.uk site but its creating a blank sitemap.xml am i doing something wrong lewis Quote:
|
Re: free google sitemap
Hi lewis,
I have opened your site and found that you has http://www.qualitechnic.co.uk/sitemap.xml But it was generated not by my module. I have test it again on 4.3.2 version, results here: http://www.ironshop.fr/ebay/sitemap.xml Thank you, Alex Quote:
|
Re: free google sitemap
sorry
i put the original sitemap back on my site has it was blank from your program I think yours would me more suitable for the xcart but i can install it again but dont want to leave a blank one on live for long thank you again lewis Quote:
|
Re: free google sitemap
I tempery altered the sitemap.php
to create the sitemap at www.qualitechnic.co.uk/sitemap1.xml and has you see its created a blank one here's the code i changed Quote:
Quote:
|
Re: free google sitemap
Yes, you made corect changes.
Can you comment these lines in sitemap.php ? PHP Code:
So it will look like this: PHP Code:
These lines allow make refresh sitemap only one time per day. Alex Quote:
|
Re: free google sitemap
Yes thats done the trick do i have leave these commented out
thank you very much thats great service:D/ Quote:
|
Re: free google sitemap
Turn off previous Sitemap Generator, then change sitemap1.xml to sitemap.xml,
then visit your admin home page. And only after that un-comment these lines. :) Quote:
|
Re: free google sitemap
Hi
Me Again I did that but when I logged in today (next Day) it created another blank sitemap.xml so re- commented them out again any idea's thanks lewis Quote:
|
Re: free google sitemap
Hi,
It's very strange. I think that problem in previous Sitemap Generator. You turned off it, but it still generate empty sitemap file. I think you comment 2 lines of code in my module and my module has generated correct sitemap.xml. These 2 lines just allow my script generate sitemap only once per day. When they are commented my script generate sitemap each time when you visit your admin home page. Alex Maybe previous Sitemap Generator used cron and you did not turn off it? Quote:
|
Re: free google sitemap
Hi Alex
Yes its strange Yes i have proved it it rewriting the sitemap every i login ok with those lines commented out 8O is there something we are missing here lewis Quote:
|
Re: free google sitemap
Lewis,
I have found bug in this file. Thank you very much for your help :) I have fixed it. Also I have made new version of this this module. New features: - you can turn on/off this module by admin area (General Settings/Google SiteMap options) - you can add any links in sitemap.xml file by admin area For updating just owerwrite sitemap.php file ! Thank you Alex UPDATED: last version on #34 post. |
Re: free google sitemap
Hi Alex
Yes You have fixed it great, its updated fine today thank you very much for a great service :D/ lewis Quote:
|
Re: free google sitemap
Hi Alex,
I hope you don't me posting corrections for this module. The way file is right now urls have no extension if X-Cart Clean URL's are used, ie the settings in admin for Clean URL's are not applied, resulting in wrong urls in sitemap.xml. Also module is not showing in modules or settings - you are missing config and language tables entries for this to work - and I took out the initial db calls form the php file - no need for them to be there. The way you had it there was no way to turn on/off the module. Moved filename in settings if users want to experiment with different names so not to override existing file. Here is how the install.txt looks like, see the red part Code:
INSTALLATION GUIDE Here is the sitemap.php, see the red part Code:
<?php There are some other changes in the php file but they are mostly cosmetic. |
Re: free google sitemap
Hi Alex
Just a quick note after looking at the sitemap.xml after the last post. I see the the categories dont have the following slash <loc>http://www.qualitechnic.co.uk/cat-Tools-Toolkits</loc> <lastmod>2010-09-05</lastmod> and the the product dont have the .html <loc>http://www.qualitechnic.co.uk/SE-Z400-Connecting-Ribbon</loc> <lastmod>2010-09-05</lastmod> is this OK Thank you Lewis Quote:
|
Re: free google sitemap
No that is not ok. And is not only the cats but your products links are missing the .html extension. See my post above for a fix.
|
Re: free google sitemap
Thanks Steve
But You Code dont match my code as mine is the latest see couple posts before Quote:
lewis Quote:
|
Re: free google sitemap
Actually the code I posted fixes the code you are reffering to. But you can still use the code you have just replace
Code:
if (is_array($cats[0])) Code:
if (is_array($cats[0])) |
Re: free google sitemap
Thanks
Great that works fine Now is there anyway of stopping it putting these and any un needed lines Quote:
Quote:
|
Re: free google sitemap
1 Attachment(s)
Thank you Steve,
I have added changes to module :) Quote:
You can remove/change these URLs from admin area on Genaral Settings/Google SiteMap options -> "Additional URLs." field. Alex UPDATED: forgot file with new version. |
Re: free google sitemap
Lewis,
Can you confirm that you see text "Google SiteMap options" in admin area on General Settings page under "General options" link ? Thank you, Alex |
Re: free google sitemap
OOOPS
Silly Me I seen that earlier thanks again lewis Quote:
|
Re: free google sitemap
Just like to thank-you for all the hard work you guys put into this, was extremely useful. Your a credit to the community :)
|
Re: free google sitemap
I am having the empty sitemap.xml problem, and when I comment out the "if ($xm_today..." browsing to /admin just gives me an empty page.
|
Re: free google sitemap
Do you have last verion of module?
Quote:
|
Re: free google sitemap
Will this work on 4.0.x?
|
Re: free google sitemap
Quote:
Yes, it should work with 4.0.x Alex |
Re: free google sitemap
I'm using the file from post#32, it could be that the file is timing out because I have ~5k products
|
All times are GMT -8. The time now is 10:02 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.