| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
#1
|
|||||||
|
|||||||
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:
Code:
2. Replaced Code:
Code:
3. Replaced Code:
Code:
4. Added Code:
Code:
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 |
|||||||
|
#2
|
|||||||||
|
|||||||||
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 |
|||||||||
#3
|
|||||||
|
|||||||
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:
Code:
Andreas Nikolaidis |
|||||||
#4
|
|||||||
|
|||||||
Re: free google sitemap
You are a gentleman, sir. Thank you for posting.
__________________
Darren X-Cart Gold 4.3.1 |
|||||||
#5
|
|||||||
|
|||||||
Re: free google sitemap
You are welcome
Andreas Nikolaidis |
|||||||
#6
|
|||||||
|
|||||||
Re: free google sitemap
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.
__________________
Thank You |
|||||||
|
#7
|
|||||||
|
|||||||
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
__________________
Darren X-Cart Gold 4.3.1 |
|||||||
#8
|
|||||||||
|
|||||||||
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>'; }
__________________
X-Cart 4.1.5 PHP 4.3.9 Mysql 4.1 VPS CentOS 4.2 Mods: Too much... * Moving to 4.1.8 and to a dedicated server * |
|||||||||
#9
|
|||||||
|
|||||||
Re: free google sitemap
For that extra condition to work we need to search two extra tables in the database.
Try to replace Code:
with Code:
I hope this works for you. Please check carefully to see if the result is correct. Andreas |
|||||||
#10
|
|||||||||
|
|||||||||
Re: free google sitemap
Quote:
Hi Andreas, thank you very much, I have tried the folowing: Code:
that is the same as you wrote but changing Code:
Code:
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...
__________________
X-Cart 4.1.5 PHP 4.3.9 Mysql 4.1 VPS CentOS 4.2 Mods: Too much... * Moving to 4.1.8 and to a dedicated server * |
|||||||||
|
|||
X-Cart forums © 2001-2020
|