Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[CONTRIBUTION] Google XML Sitemap Feed - by Chemo


Guest

Recommended Posts

The experimental Google XML sitemap service was announced on 2 June 2005 and represents a huge development in terms of crawler technology. This contribution is designed to create the sitemap XML feed per the protocol specification delineated by Google.

 

WHAT THIS CONTRIBUTION DOES

This contribution creates a sitemap index file and also 2 additional sitemaps (products and categories). It is designed to be run via CRON (primary and preferred method) and also browser as needed.

 

Once the XML feeds are created a store owner should only submit the sitemap index which points to the product and category sitemaps.

 

WHY SHOULD A STORE INSTALL A GOOGLE XML SITEMAP?

...because Google wants to experiment with the service as a means to improve their search result quality. Any time Google wants to experiment I'm in...

 

NOTES

The code is THOROUGHLY documented so that other developers can jump on and help. I put a huge amount of time with the documentation on this one so hopefully I'll get some help with future development.

 

...besides, having quality code AND quality documentation is just sexy :)

 

DOWNLOAD

Google XML Sitemap Feed - by Chemo

 

Enjoy!

 

Bobby

Link to comment
Share on other sites

Hi Bobby,

 

This sounds pretty interesting, thanks for posting it in the forums. :thumbsup:

 

Is this Google-Sitemap something to do with the "usual" sitemap? Would i have to replace the sitemap i currently have with the google-sitemap?

 

Thanks,

 

Sandra

HIM - Dark Light - Out on 26/09/05
Link to comment
Share on other sites

The Google sitemap is an XML feed that will be used by the Google spider to crawl your site. Read about it here: [RUL=https://www.google.com/webmasters/sitemaps/docs/en/about.html]About the Google XML Sitemap Feed[/url].

 

Also, there is a FAQ located here: Google XML Sitemap FAQ.

 

In a nutshell, it's a Google experiment...the effect can only be positive and will NOT detract from normal spider activity. Per Google, "In most cases, webmasters will benefit from Sitemap submission, and in no case will you be penalized for it".

 

Bobby

Link to comment
Share on other sites

Open the file and find this line of code on 66:

$cache->get_cache('GLOBAL');

and change it to this:

//$cache->get_cache('GLOBAL');

Save the file and try it again! :)

 

Bobby

Link to comment
Share on other sites

I ran right away to give this a try and got

 

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/.asylum/cinnie/homeandgardengiftsandcollectibles/googlesitemap/sitemap.class.php on line 83

ERROR: Google Product Sitemap Generation FAILED! ERROR: Google Category Sitemap Generation FAILED! Generated Google Sitemap Index Successfully

 

when running the googlesitemap/index.php

Edited by wendyjames

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

Open the file and find this line of code on 66:

$cache->get_cache('GLOBAL');

and change it to this:

//$cache->get_cache('GLOBAL');

Save the file and try it again! :)

 

Bobby

alright did that

 

now get this

ERROR: Google Product Sitemap Generation FAILED! ERROR: Google Category Sitemap Generation FAILED! ERROR: Google Sitemap Index Generation FAILED!

Link to comment
Share on other sites

This is the code on line 83:

	function ConnectDB(){
 $this->link_id = mysql_connect($this->$host, $this->user, $this->pass);
} # end function

Basically, it's the database connection...so, there is an error with the credentials being provided.

 

This is puzzling as it is passing the same credentials to the class that are defined in the configure.php file. So, if it works on the store it should work for the class as well.

 

The GoogleSitemap class is initialized with this code:

$google = new GoogleSitemap(DB_SERVER, DB_SERVER_USERNAME, DB_DATABASE, DB_SERVER_PASSWORD);

As you can see, it's using the defined constants from configure.php

 

Are there any other errors generated? Maybe the actual problem is a bit higher but that is the script kill point?

 

Bobby

Link to comment
Share on other sites

alright did that

 

now get this

ERROR: Google Product Sitemap Generation FAILED! ERROR: Google Category Sitemap Generation FAILED! ERROR: Google Sitemap Index Generation FAILED!

Did you upload the dummy XML files and change the permissions to 777 ???

 

Bobby

Link to comment
Share on other sites

Tell me about your setup...

 

Is your store installed in the root? Like domain.com/ or is it domain.com/directory/?

 

Where did you upload the dummy files?

 

Bobby

Link to comment
Share on other sites

Not that I can see. I copy and pasted the whole page (error)

Could I enter that information manually or does it have to be grabbed from the configure.php?

 

I don't know a whole bunch about coding, but I looked at the sitemap.class.php and it even made sense to me. lol Not sure why it is happening though, and so you know my site is not having any problems right now. I checked, just to be sure.

 

lol You are very busy so I can wait.. if you want to help one at a time. =)

Edited by wendyjames

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

Dummy files should be in the catalog directory like this:

 

domain.com/catalog/sitemapindex.xml

domain.com/catalog/sitemapproducts.xml

domain.com/catalog/sitemapcategories.xml

 

Move them to the catalog directory, set the permissions as 777, and give it one more try. :)

 

Bobby

Link to comment
Share on other sites

and I get this error :

Fatal error: Call to undefined function: tep_session_is_registered() in /home/i8carati/public_html/catalog/includes/functions/html_output.php on line 237

 

Dummy files are chmoded to 777 and stored on public_html ( root)

sitemap directory is under mydomain.com/catalog/

 

Any idea ?

 

Thanks

Outside links in signatures are not allowed!

Link to comment
Share on other sites

wendy this might be the error..but chemo should double check..

 

This is the code on line 83:

	function ConnectDB(){
 $this->link_id = mysql_connect($this->$host, $this->user, $this->pass);
} # end function

 

not sure if im right but looks like there is an errror on line 83 and should read

  $this->link_id = mysql_connect($this->host, $this->user, $this->pass);

 

instead of

$this->link_id = mysql_connect($this->$host, $this->user, $this->pass);

as there is an extra $ in this line

Edited by theman
Link to comment
Share on other sites

Dummy files should be in the catalog directory like this:

 

domain.com/catalog/sitemapindex.xml

domain.com/catalog/sitemapproducts.xml

domain.com/catalog/sitemapcategories.xml

 

Move them to the catalog directory, set the permissions as 777, and give it one more try. :)

 

Bobby

same error once again

Link to comment
Share on other sites

omg...you are absolutely correct. I'll upload another version...in the meantime everyone correct that.

 

Good catch!

 

Bobby

Link to comment
Share on other sites

omg...you are absolutely correct.  I'll upload another version...in the meantime everyone correct that.

 

Good catch!

 

Bobby

alright now that thats fixed i get another error :~

 


Fatal error: Call to undefined function: tep_session_is_registered() in /homepages/9/*********/htdocs/***/catalog/includes/functions/html_output.php on line 207

 

here are my lines 207 - 221

	if (!tep_session_is_registered('customer_id') && ENABLE_PAGE_CACHE == 'true' && class_exists('page_cache')) {
 $link .= $separator . '<osCsid>';
	 $seo_link .= $separator . '<osCsid>';
	 $seo_rewrite_link .= $separator . '<osCsid>';
} elseif (isset($_sid)) {
 $link .= $separator . $_sid;
   $seo_link .= $separator . $_sid;
   $seo_rewrite_link .= $separator . $_sid;
}
  
if ($seo == 'true') {
 return ($seo_rewrite_type == 'Rewrite' ? $seo_rewrite_link : $seo_link);
} else {
 return $link;
}

Edited by theman
Link to comment
Share on other sites

...OK...try this:

 

Somewhere near the top of googlesitemap/index.php paste this code:

function tep_session_is_registered( $var ){
   return false;
}

If it works for you I'll roll it into the next release immediately...

 

The reason there is that error is because I had to eliminate the sessions all together...or it would not run under CRON properly. So, it looks like that is the last piece of the puzzle.

 

I did not experience that problem since it was developed on a dev server with the new SEO URLs.

 

Try it and let me know how it goes...

Link to comment
Share on other sites

I have exactly the same error now, but it says line 205. lol

 

How do you guys do it? I would never ever have spotted an extra $. Guess that is why I am just a housewife. lol

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

Wendy...I offered a quick bit of code in the previous post. Can you grab it and save it somewhere near the top of googlesitemap/index.php? Let me know if that works for you...

 

Bobby

Link to comment
Share on other sites

adding

 

function tep_session_is_registered( $var ){

return false;

}

 

worked for me Chemo... atleast I think it did. I get this now

 

 

Generated Google Product Sitemap Successfully Generated Google Category Sitemap Successfully Generated Google Sitemap Index Successfully All files generated successfully. If you have not already submitted the sitemap index to Google click the link below. http://www.google.com/webmasters/sitemaps/...itemapindex.xml

 

oops, except that the link is not clickable and has extra vharacters in it... not sure why it pasted right

 

says

http%3A%2F%2F<snip on request>%2Fsitemapindex.xml

Edited by mattice

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

that tepsession error goes away but then i get the

ERROR: Google Product Sitemap Generation FAILED! ERROR: Google Category Sitemap Generation FAILED! ERROR: Google Sitemap Index Generation FAILED!

Great! That is progress!

 

Now, let's work on those paths for the files. Maybe I didn't make it clear enough in the install file.

 

The dummy files should be uploaded to the CATALOG directory wherever that may be...whether it is in the root or in a directory.

 

Are the dummy files in the store root?

adding

 

function tep_session_is_registered( $var ){

  return false;

}

 

worked for me Chemo... atleast I think it did. I get this now

Generated Google Product Sitemap Successfully Generated Google Category Sitemap Successfully Generated Google Sitemap Index Successfully All files generated successfully. If you have not already submitted the sitemap index to Google click the link below.

Congratulations! It is installed and ready to view! Take a look at the XML files and make sure the data is good...

 

Bobby

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...