Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Google XML Sitemap SEO


Jack_mcs

Recommended Posts

It looks like a path problem. You might want to read through this thread to see fixes for that.

 

Jack

 

Jack

 

Are you saying it might be a path problem becuase the full paths are not shown in the error? I removed the full path because I did not want to show them here on the forum. I will search and see what I can find.

 

Everything was working fine until I wanted to change it to "Products Viewed".

 

Thanks!

Edited by projman
Link to comment
Share on other sites

Yes, that is what I meant. If that is not the correct output, then I don't know what the problem is. I don't provide support for specially coded projects so you will need to figure that one out yourself.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Hi Jack, Thx for the contribution. I have downloaded the latest from the 6th March but having problems with specials. We dont have any specials but still the sitemapindex.xml file is still showing the line

 

<sitemap>

<loc>http://www.fantaby.se/foretag/shop/sitemapspecials.xml</loc>

<lastmod>2009-03-15</lastmod>

</sitemap>

 

because of this we are getting an error message from Google saying the sitemapspecials.xml file is empty. I would have thought that if there were no specials, this code would have been left out/deleted from the sitemapindex.xml file so that Google wouldnt be led to the empty file. Or has something gone wrong with just our installation?

 

Many thanks/ Luke

Link to comment
Share on other sites

Jon I have the same problem. Let me know if you figure out what fixes that. I will do the same if I figure it out.

 

Thanks.

Hi Jason,

 

I think I fixed it - Try This:

	function GenerateProductSitemap(){
      $sql = "SELECT p.products_id as pID, p.products_date_added as date_added, p.products_last_modified as last_mod, p.products_ordered, pd.products_viewed as viewed
               FROM " . TABLE_PRODUCTS . " p left join " .
               TABLE_PRODUCTS_DESCRIPTION . " pd on (p.products_id = pd.products_id)  
               WHERE products_status='1' 
               ORDER BY pd.products_viewed DESC";
	if ( $products_query = $this->DB->Query($sql) ){
		$this->debug['QUERY']['PRODUCTS']['STATUS'] = 'success';
		$this->debug['QUERY']['PRODUCTS']['NUM_ROWS'] = $this->DB->NumRows($products_query);
		$container = array();
		$number = 0;
		$top = 0;
		while( $result = $this->DB->FetchArray($products_query) ){
			$top = max($top, $result['viewed']);
			$location = $this->hrefLink(FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], 'NONSSL', false);
			$lastmod = $this->NotNull($result['viewed']) ? $result['viewed'] : $result['date_added'];
			$changefreq = GOOGLE_SITEMAP_PROD_CHANGE_FREQ;
			$ratio = $top > 0 ? $result['viewed']/$top : 0;
			$priority = $ratio < .1 ? .1 : number_format($ratio, 1, '.', ''); 

			$container[] = array('loc' => htmlspecialchars(utf8_encode($location)),
			                     'lastmod' => date ("Y-m-d", strtotime($lastmod)),
								 'changefreq' => $changefreq,
								 'priority' => $priority
			                     );
			if ( sizeof($container) >= 50000 ){
				$type = $number == 0 ? 'products' : 'products' . $number;
				$this->GenerateSitemap($container, $type);
				$container = array();
				$number++;
			}
		} # end while
		$this->DB->Free($products_query);			
		if ( sizeof($container) > 1 ) {
			$type = $number == 0 ? 'products' : 'products' . $number;
			return $this->GenerateSitemap($container, $type);
		} # end if			
	} else {
		$this->debug['QUERY']['PRODUCTS']['STATUS'] = 'false';
		$this->debug['QUERY']['PRODUCTS']['NUM_ROWS'] = '0';
	}
} # end function

Link to comment
Share on other sites

Hi Jack, Thx for the contribution. I have downloaded the latest from the 6th March but having problems with specials. We dont have any specials but still the sitemapindex.xml file is still showing the line

 

 

 

because of this we are getting an error message from Google saying the sitemapspecials.xml file is empty. I would have thought that if there were no specials, this code would have been left out/deleted from the sitemapindex.xml file so that Google wouldnt be led to the empty file. Or has something gone wrong with just our installation?

 

Many thanks/ Luke

Code was posted a few pages back to remove the manufacturers entry. You can use the same for specials by applying it to the specials section.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Hi Jason,

 

I think I fixed it - Try This:

	function GenerateProductSitemap(){
      $sql = "SELECT p.products_id as pID, p.products_date_added as date_added, p.products_last_modified as last_mod, p.products_ordered, pd.products_viewed as viewed
               FROM " . TABLE_PRODUCTS . " p left join " .
               TABLE_PRODUCTS_DESCRIPTION . " pd on (p.products_id = pd.products_id)  
               WHERE products_status='1' 
               ORDER BY pd.products_viewed DESC";
	if ( $products_query = $this->DB->Query($sql) ){
		$this->debug['QUERY']['PRODUCTS']['STATUS'] = 'success';
		$this->debug['QUERY']['PRODUCTS']['NUM_ROWS'] = $this->DB->NumRows($products_query);
		$container = array();
		$number = 0;
		$top = 0;
		while( $result = $this->DB->FetchArray($products_query) ){
			$top = max($top, $result['viewed']);
			$location = $this->hrefLink(FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], 'NONSSL', false);
			$lastmod = $this->NotNull($result['viewed']) ? $result['viewed'] : $result['date_added'];
			$changefreq = GOOGLE_SITEMAP_PROD_CHANGE_FREQ;
			$ratio = $top > 0 ? $result['viewed']/$top : 0;
			$priority = $ratio < .1 ? .1 : number_format($ratio, 1, '.', ''); 

			$container[] = array('loc' => htmlspecialchars(utf8_encode($location)),
			                     'lastmod' => date ("Y-m-d", strtotime($lastmod)),
								 'changefreq' => $changefreq,
								 'priority' => $priority
			                     );
			if ( sizeof($container) >= 50000 ){
				$type = $number == 0 ? 'products' : 'products' . $number;
				$this->GenerateSitemap($container, $type);
				$container = array();
				$number++;
			}
		} # end while
		$this->DB->Free($products_query);			
		if ( sizeof($container) > 1 ) {
			$type = $number == 0 ? 'products' : 'products' . $number;
			return $this->GenerateSitemap($container, $type);
		} # end if			
	} else {
		$this->debug['QUERY']['PRODUCTS']['STATUS'] = 'false';
		$this->debug['QUERY']['PRODUCTS']['NUM_ROWS'] = '0';
	}
} # end function

 

 

That worked wonderfully. Not sure what you did. Perhaps Ill have more time later to compare. Thanks a lot Jon.

Link to comment
Share on other sites

Hi Jack.

 

Thank you for the update. It's working perfectly.

 

May I ask, what is the advantage of the extra feeds?, and have 'new products' been omitted for a reason?

What about our static pages? conditions, shipping etc (I also have a few tutorials). Would it be worth me manually creating another XML file for these pages?

 

Thanks.

 

Ken

Link to comment
Share on other sites

New products will show up in the products sitemap. A separate sitemap could be created for those but since they would be duplicates, I don't think it would gain anything.

 

I toyed with the idea of adding a sitemap for the static pages but those are usually of less importance and the search engines will find them quick enough on their own, especially if an on-site sitemap contribution is installed. So I'm not sure I will be changing the code for that but it might be a good idea to create a separate one for those. It could be done manually in a few minutes, using one of the sitemaps from this contribution as a guide, and isn't something that would change, at least not often. It may not make a big difference but any exposure is better than none.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Hi Jack.

 

Thanks for the info.

 

A separate sitemap could be created for those but since they would be duplicates

 

Well the specials.xml is also a duplicate.

 

I have (for example)

 

http://mysite/product_info.php?products_id=312

 

in the sitemapspecials.xml. And then it is repeated in sitemapproducts.xml

 

Surely this is a duplicate in the same way that new products would be?

 

Regards.

 

Ken.

Link to comment
Share on other sites

Yes, they also appear. My thinking is that a new products sitemap would be more likely to be empty. Although, as some have mentioned, so is the specials and manufacturers so I will probably change the code to allow those to be options.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

That worked wonderfully. Not sure what you did. Perhaps Ill have more time later to compare. Thanks a lot Jon.

 

Jason,

 

I found another error:

 

Locate this line in the function:

$lastmod = $this->NotNull($result['viewed']) ? $result['viewed'] : $result['date_added'];

 

Change it back to the original line:

$lastmod = $this->NotNull($result['last_mod']) ? $result['last_mod'] : $result['date_added'];

 

If I find anything else, I will let you know, but it looks good now.

Edited by projman
Link to comment
Share on other sites

  • 3 weeks later...

I found some issues with the original contribution by Chemo that I used.

Google started to show errors and redirects in my Webmaster Tools sitemaps.

 

Looking for a solution I found your *updated* version and I suddenly discovered that I was using an incomplete version since day 1 :blush:

 

Your installation was easy and it worked out of the box.

 

Just one question: Which files should I remove from the domain.com/googlesitemap/ to be on the safe side?

 

Thanks.

Norman in 't Veldt

 

Moderator

osCommerce The Netherlands

Link to comment
Share on other sites

You don't need to remove any files. Just upload the ones from this contribution. They are all the same except for a few.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

You don't need to remove any files. Just upload the ones from this contribution. They are all the same except for a few.

 

Jack

 

Thanks, but that is not what I mean, sorry for that.

 

In the googlesitemap map there are a lot of files, one is an index.html whit installation instructions.

This googlesitemap is accessable via your browser and thus can someone see the install instruction.

I removed that file so now there is only the index.php which will generate the sitemaps.xml files.

 

Just want to know if that construction is safe or do I need to remove other files or change the access rights?

Norman in 't Veldt

 

Moderator

osCommerce The Netherlands

Link to comment
Share on other sites

You can remove that if you want. The contents of that directory is known to anyone familiar with the contribution so having the install instructions doesn't provide any information that can hurt a site.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

You can remove that if you want. The contents of that directory is known to anyone familiar with the contribution so having the install instructions doesn't provide any information that can hurt a site.

 

Jack

 

Thanks!

Norman in 't Veldt

 

Moderator

osCommerce The Netherlands

Link to comment
Share on other sites

You need to extract the contents and then click on install.

 

Jack

Hi jack Thanks for your reply I have installed a few contributions on my site already so I know how to open a zip file etc but I when I try to get the link for the instal documents I.E. does not show the document just tells me I am being redirected which never happens.

Link to comment
Share on other sites

My reply had nothing to do with opening the zip file. The way the install document was written won't allow it to be ran from within the zip file. Have you extracted the contents of the zip file and placed them somewhere on your computer and clicked on the install file from there?

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

My reply had nothing to do with opening the zip file. The way the install document was written won't allow it to be ran from within the zip file. Have you extracted the contents of the zip file and placed them somewhere on your computer and clicked on the install file from there?

 

Jack

Hi Jack Thanks again for your support tried that, didn't work on the pc but managed to get it from the laptop obviously an issue with my old desktop. I have installed a couple of your contribs so far with no problem and just thought I'd say thanks a million for your hardwork.

Lori

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...