Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[CONTRIBUTION] Google XML Sitemap Feed - by Chemo


Guest

Recommended Posts

In order to make this by the way excellent contribution to work with the "other" (topic 129041) SEO URL's contribution i had to make some little changes.

 

I hope it's not a problem i post them here and perhaps you can do something with it.

 

 

 

In googlesitemap/index.php around line 58:

 

// SEO OTHER BEGIN

if ( file_exists(DIR_WS_CLASSES . 'seo.class.php') ){

require_once(DIR_WS_CLASSES . 'seo.class.php');

$seo_urls = new SEO_URL($languages_id);

} else if ( file_exists(DIR_WS_CLASSES . 'url_rewrite.php') ){

require_once(DIR_WS_CLASSES . 'url_rewrite.php');

$other_rewrite = true;

}

// SEO OTHER END

 

 

In google/sitemap.class.php just below function GenerateProductSitemap(){

 

 

// SEO OTHER BEGIN

global $other_rewrite;

 

if (!$other_rewrite) {

$sql = "SELECT products_id as pID, products_date_added as date_added, products_last_modified as last_mod, products_ordered

FROM " . TABLE_PRODUCTS . "

WHERE products_status='1'

ORDER BY products_ordered DESC";

} else {

$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_name, ptc.categories_id

FROM " . TABLE_PRODUCTS . " AS p LEFT JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " AS ptc

ON ptc.products_id=p.products_id

LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " AS pd

ON pd.products_id=p.products_id

WHERE p.products_status='1'

ORDER BY p.products_ordered DESC";

}

// SEO OTHER END

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['products_ordered']);

// SEO OTHER BEGIN

if (!$other_rewrite)

$location = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], 'NONSSL', false);

else

$location = tep_href_link(FILENAME_DEFAULT, 'cPath=' . tep_get_product_path($result['pID']) . '/' . $result['products_name'], 'NONSSL', false);

// SEO OTHER END

$lastmod = tep_not_null($result['last_mod']) ? $result['last_mod'] : $result['date_added'];

$changefreq = GOOGLE_SITEMAP_PROD_CHANGE_FREQ;

$ratio = $result['products_ordered']/$top;

$priority = $ratio < .1 ? .1 : number_format($ratio, 1, '.', '');

Link to comment
Share on other sites

Hi,

 

I have installed this contrib and this may sound like a really stoopid question but when you setup the cron job would this be the correct path if my store is in root

 

public_html/googlesitemap/index.php

 

Also how would I know that it has run okay, would I have to wait until midnight??

 

Mark

Lifes a bitch, then you marry one, then you die!

Link to comment
Share on other sites

Google has visited my page but is giving the following message:

 

Invalid date

An invalid date was found. Please validate your Sitemap before resubmitting

 

 

Could someone tell me wat to change (Dutch site)

Link to comment
Share on other sites

Misa, I just submitted mine, can you tell how long it took for google to visit your site ?

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

But Joop,

 

Did you get the same error with invalid date? and what didi you do about it?

 

Your site is also in the Netherlands?.....or is this not the reason?

Link to comment
Share on other sites

for the datestamp, it is expecting either just a date, or a datetimestamp including the offset to GMT time.

 

If you append 'O' (uppercase O not zero) it will add eg +02:00 for servers based in the netherlands ...

 

  'lastmod' => date ("Y-m-d\TH:i:sO", strtotime($lastmod)),

I've made this correction, now waiting on google ...

 

Carine

Edited by bruyndoncx

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

In the catalog/googlesitemap/sitemap.class.php file, for each occurrance of the date format string

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Ok, I found 2 and have changed it.

 

'lastmod' => date ("Y-m-d\TH:i:s O", strtotime($lastmod)),

There are actually 3 occurances, 1 for the main index file, 1 for categories, 1 for products.

 

Also note, that the 'O' should be immediately after 's', no spacing in between.

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Hello Bobby,

 

I always get this error:

 

I uploaded the files and changed the permission to 777. I can see the index.html file.Do you have any idee wy I cannot see the index.php ?

 

Thx,

 

Hans

 

http://www.pricebreaker.be/google/index.php

 

The page cannot be displayed

There is a problem with the page you are trying to reach and it cannot be displayed.

 

--------------------------------------------------------------------------------

 

Please try the following:

 

Open the www.cartridge-online.be home page, and then look for links to the information you want.

Click the Refresh button, or try again later.

 

Click Search to look for information on the Internet.

You can also see a list of related sites.

 

HTTP 500 - Internal server error

Internet Explorer

Link to comment
Share on other sites

Ok.

 

Found them on line 372-405-449

 

'lastmod' => date ("Y-m-d\TH:i:sO", strtotime($lastmod)),

 

Please correct me if it's wrong.

Link to comment
Share on other sites

Hello Bobby,

 

I always get this error:

 

I uploaded the files and changed the permission to 777. I can see the index.html file.Do you have any idee wy I cannot see the index.php ?

 

Thx,

 

Hans

 

http://www.pricebreaker.be/google/index.php

 

The page cannot be displayed

There is a problem with the page you are trying to reach and it cannot be displayed.

 

--------------------------------------------------------------------------------

 

Please try the following:

 

Open the www.cartridge-online.be home page, and then look for links to the information you want.

Click the  Refresh button, or try again later.

 

Click  Search to look for information on the Internet.

You can also see a list of related sites.

 

HTTP 500 - Internal server error

Internet Explorer

 

 

Hans,

 

The files should be in the googlesitemap directory.

Can you change hte directory name and try again.

The directory name is hardcoded in the index.php script in order to call the class file..

 

Carine

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

I've been scratching my head on this one. Hopefuly somebody can explain what's happening. When I run the script, the output is successful but instead of creating the three files in my root dir named:

 

sitemapproducts.xml

sitemapcategories.xml

sitemapindex.xml

 

i get three files in my root dir named:

 

googlesitemapsitemapproducts.xml

googlesitemapsitemapcategories.xml

googlesitemapsitemapindex.xml

 

it appears to be amending the name of the googlesitemap directory to my files. I haven't edited any of the code. The googlesitemap directory is in my root dir, and it runs without error. Just the naming of the files is wrong.

Link to comment
Share on other sites

Just wanted to say I installed this very, very easily. I just followed the instructions and don't seem to have had any of the errors that others are reporting.

 

Fantastic, and easy to follow for beginners instructions as usual Bobby and yet another fantastic contribution.

 

It is getting to the stage where I install anything with your name against it as I know it will be an excellent addition.

 

You are an A1 Geezer as we say in the UK

 

regards

 

Mogsta

Link to comment
Share on other sites

can you re-upload the original index.php and sitemap.class.php file to the googlesitemap directory ?

to make sure no typo's slipped in ?

 

then next question is, what is your setup (using any of chemo's contributions? ), standard MS2 or a loaded release or anything else peculiar ?

PHP4 or 5 ?

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Hmm,i duno if this is something i've done, or a contrib bug, but when i generate a new sitemap, it appears to be duplicating all the categorie URL's - one in the re-written format and one in the cpath=? format.

Like this

 

Just wondering if anybody else was having this problem, or if it was just me :D

 

Cheers

Fatmcgav

Link to comment
Share on other sites

Get with me on instant messenger...I have some code that I want to try that should fix the problem. I want to test it at least once before releasing it...howver, if it works it'll have complete compatibility with the Ultimate SEO URLs :)

 

BTW, I have another release uploaded that fixes the rest of the issues discussed. I'd hold off on upgrading though until we test the SEO URLs compatibility code...it might be worth it.

 

As a side note, upgrading is easy...just overwrite the 2 main files: googlesitemap/index.php and googlesitemap/sitemap.class.php :)

 

Bobby

Link to comment
Share on other sites

I've uploaded another release that corrects the issue with forming Ultimate SEO URLs.

 

Also, added some nice info on the index.php file when all sitemaps are created successfully.

 

1) Submission link

2) CRON command

3) Sitemap index link

4) Products sitemap link

5) Categories sitemap link

 

We're getting closer to a stable, mature release for this contribution! I want to thank everyone that is helping test and develop this code!

 

To upgrade simply download the latest release and overwrite the two main files:

 

googlesitemap/index.php

googlesitemap/sitemap.class.php

 

Download the latest release

 

Enjoy!

 

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