Jump to content
Jack_mcs

Google XML Sitemap SEO

Recommended Posts

Hi Jack!

I installed this contribution today, but although permissions for the 6 xml files included are set to 777, it gives me the following error:

What result do you get when you use the alternate option? The test option?

Share this post


Link to post
Share on other sites

What result do you get when you use the alternate option? The test option?

With the alternate i got the same results.

With the test option i don't know, because i didn't understand yet how to use the test option...

(if u mean to set Enable Diagnostic Output to True and run ....googlesitemap/index.php again, i did it and got the same results)

Edited by Vassilis

Share this post


Link to post
Share on other sites

With the alternate i got the same results.

With the test option i don't know, because i didn't understand yet how to use the test option...

(if u mean to set Enable Diagnostic Output to True and run ....googlesitemap/index.php again, i did it and got the same results)

The results you posted are not what one gets when the dianostic is ran so it seems you have a problem in your installation.

Share this post


Link to post
Share on other sites

The results you posted are not what one gets when the dianostic is ran so it seems you have a problem in your installation.

I don't get it, installation is quite easy: i ran the sql file using phpmyadmin, i copied to my catalog directory the 6 dummy xml files (and assigned 777 permission to all 6 of them), i copied the xsl file to my catalog directory (i left it as it was, 644 permission). Then i copied the googlesitemap directory (with all it's files) to my catalog directory. The results were as i posted them, either i choose standard or alternate, either if i choose "yes" or "no" at "Enable Diagnostic Output".

 

/catalog/sitemapproducts.xml

/catalog/sitemappages.xml

/catalog/sitemapcategories.xml

/catalog/sitemapmanufacturers.xml

/catalog/sitemapspecials.xml

/catalog/sitemapindex.xml

/catalog/gss.xsl

/catalog/googlesitemap/index.php

/catalog/googlesitemap/sitemap.class.php

/catalog/googlesitemap/sitemap.class_Alternate.php

 

Where could my mistake be in my installation?

Edited by Vassilis

Share this post


Link to post
Share on other sites

I don't get it, installation is quite easy: i ran the sql file using phpmyadmin, i copied to my catalog directory the 6 dummy xml files (and assigned 777 permission to all 6 of them), i copied the xsl file to my catalog directory (i left it as it was, 644 permission). Then i copied the googlesitemap directory (with all it's files) to my catalog directory. The results were as i posted them, either i choose standard or alternate, either if i choose "yes" or "no" at "Enable Diagnostic Output".

 

Where could my mistake be in my installation?

It sounds like you did everything correctly. It might be that you somehow added the database changes twice and now have duplicate configure options which means you may set one in admin but it isn't the one being checked. Other than that, I can't think of anything else.

Share this post


Link to post
Share on other sites

Hi Jack,

 

Sorry to bother you but I am at a loss. :blush:

 

Everything has been running smoothly for a long time.

 

But suddenly I am receiving this from my Cron Job as seen at this page - http://handeshobbies.com/googlesitemap/index.php

 

I haven't changed anything other than adding and/or updating products through my admin.

I used to receive clickable links instead of all that Array stuff.

I am not sure where to start looking.

Could it be something changed at my server?


- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Share this post


Link to post
Share on other sites

But suddenly I am receiving this from my Cron Job as seen at this page - http://handeshobbies.com/googlesitemap/index.php

 

I haven't changed anything other than adding and/or updating products through my admin.

I used to receive clickable links instead of all that Array stuff.

I am not sure where to start looking.

Could it be something changed at my server?

It's indicating the manufacturers sitemap failed. Perhaps the permissions on the file are not correct for some reason. You could also run the diagnostic and/or try the alternate sitemap file.

Share this post


Link to post
Share on other sites

Thank you Jack for such a quick reply.

 

It's indicating the manufacturers sitemap failed.

Perhaps I don't understand... I thought it was the Specials Sitemap that failed. Which is strange, there are a couple of items on special.

 

Perhaps the permissions on the file are not correct for some reason.

I checked all related files and the permissions are set as they always were; 755.

 

You could also run the diagnostic and/or try the alternate sitemap file.

 

Sorry Jack, but I am now terribly lost.

Were would I find information regarding running the diagnostic?

I was using the alternate sitemap file, but I did try switching them with the same results.

 

I also deleted all the google sitemap files on the server and uploaded my backups (originals). Still no luck.

 

Dazzed and confused.... crying.gif


- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Share this post


Link to post
Share on other sites

I have been doing a little more digging around in my admin panel, not sure if this might be useful...

 

I had cleared my cache files a few days ago, but today they do not exsist even though I browsed my catalog.

 

I have 4 products on special, but my specials page only shows 2 even though it's set to show 9.

 

:huh:


- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Share this post


Link to post
Share on other sites

Were would I find information regarding running the diagnostic?

In the settings for this contribution.

Share this post


Link to post
Share on other sites

Very, very strange...

 

All is back to working just fine today! :blink:

 

Thank you Jack for coming to my rescue.

 

My head is stuck in muck...

 

For the life of me I can not find anything in my admin panel pertaining to Google Sitemap settings nor in the contribs directions discussing diagnostics. :(

 

Me needs big kick! whistling.gif


- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Share this post


Link to post
Share on other sites

For the life of me I can not find anything in my admin panel pertaining to Google Sitemap settings nor in the contribs directions discussing diagnostics. :(

Then maybe you aren't using this contribution (there are others simularly named) or you didn't upload the database changes?

Share this post


Link to post
Share on other sites

Oh DANG... my bad Jack! :(

 

Looks like I am still using version 1.1 :blush:

 

Should I leave my setup alone or update to v1.5?


- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Share this post


Link to post
Share on other sites

Oh DANG... my bad Jack! :(

 

Looks like I am still using version 1.1 :blush:

 

Should I leave my setup alone or update to v1.5?

There a big difference between those two versions so I suggest updateing.

Share this post


Link to post
Share on other sites

There a big difference between those two versions so I suggest updateing.

 

Thank you Jack!

 

I'll get right on it.

 

As always, I appreciate all your help. :)


- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Share this post


Link to post
Share on other sites

Short of that, you need a server with higher limits.

 

I changed to a new and powerfull server.

 

Th first time I used again /with the standar products that comes with osc, all right).

 

After adding about 50000products I get this:

 

sitemapproducts.xml

 

	<url>
	<loc></loc>
	<lastmod>2011-01-12</lastmod>
	<changefreq>weekly</changefreq>
	<priority>1.0</priority>
</url>

 

All <locs> with empty url.

Share this post


Link to post
Share on other sites

I changed to a new and powerfull server.

 

Th first time I used again /with the standar products that comes with osc, all right).

 

After adding about 50000products I get this:

 

sitemapproducts.xml

 

All <locs> with empty url.

I'm not sure I understand what you said. Are you saying the sitemap files are correct if you standard products but not yours. And then it only fails for yours if there are a large number? Does it work with just one of your products?

Share this post


Link to post
Share on other sites

This is my configuration for

Google XML SEO

Sitemap file Standard

Enable Manufacturers Map false

Enable Specials Map false

Enable Standard Pages Map false

Enable Diagnostic Output true

Exclude these pages

 

Then i go to:

http://www. myweb .com/googlesitemap/index.php

 

I use mozilla, it stays about 10seconds loading the script and then a white page.

 

For that I do a sql query (I have more than 50000products):

 

DELETE FROM products WHERE products_id > '17203';
DELETE FROM products WHERE products_id = '0';

DELETE FROM products_description WHERE products_id > '17203';
DELETE FROM products_description WHERE language_id = '0';

DELETE FROM products_to_categories WHERE products_id > '17203';

 

It generates the file:

2,00 MB (2.097.421 bytes)

 

but opening the file I see there is not url info (empty) <loc>*here is nothing*</loc>

 

For that I remove more products, all categories, and disable&delete the specials, manufacturers and 1 categories :

DELETE FROM products WHERE products_id > '8000';
DELETE FROM products WHERE products_id = '0';

DELETE FROM products_description WHERE products_id > '8000';
DELETE FROM products_description WHERE language_id = '0';

DELETE FROM products_to_categories WHERE products_id > '8000';

 

but again there is not information inside <loc></loc>

 

this is the log:

Write /xxx /sitemapproducts.xml

Generated Google Product Sitemap Successfully

 

ERROR: Google Category Sitemap Generation FAILED!

 

Google Sitemap Manufacturers not generated - no Manufacturers found!

 

Google Sitemap Specials not generated - no specials found!

 

Write /xxx /sitemapindex.xml

Generated Google Sitemap Index Successfully

 

Array

(

[QUERY] => Array

(

[PRODUCTS] => Array

(

[sTATUS] => success

[NUM_ROWS] => 8001

)

 

[CATEOGRY] => Array

(

[sTATUS] => success

[NUM_ROWS] => 1

)

 

[MANUFACTURERS] => Array

(

[sTATUS] => success

[NUM_ROWS] => 0

)

 

[sPECIALS] => Array

(

[sTATUS] => success

[NUM_ROWS] => 0

)

 

)

 

[sAVE_FILE_XML] => Array

(

[0] => Array

(

[file] => /xxx /sitemapproducts.xml

[status] => success

[file_exists] => true

)

 

[1] => Array

(

[file] => /xxx /sitemapindex.xml

[status] => success

[file_exists] => true

)

 

)

 

)

 

Im generating the sitemaps on blocks of 10000products(+ - by supplier) and then modifing the sitemapindex.xml adding the different blocks.

Sometimes works fine and I dont know why or where is the problem.

 

Also see in the log: [CATEOGRY]

 

what are the requirements to generate the products sitemaps?

I also have HeaderTagasSeo contrib and Robert´s USU5 PRO.

Edited by bhbilbao

Share this post


Link to post
Share on other sites

I forgot to comment. With the googlesitemap/index.php and googlesitemap/sitemap.class.php of your last release didnt work in any maner (standard or alternative). I downloaded other archives, these are:

index.php

<?php
/**
* Google XML Sitemap Feed Cron Script
*
* The Google 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 specification delineated 
* by Google.  This cron script will call the code to create the scripts and 
* eliminate the session auto start issues. 
* @package Google-XML-Sitemap-Feed
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 1.2
* @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers
* @link http://www.google.com/webmasters/sitemaps/docs/en/about.html About Google Sitemap 
* @copyright Copyright 2005, Bobby Easland 
* @author Bobby Easland 
* @filesource
*/

       chdir('../');
       /**
        * Option to compress the files
        */
       define('GOOGLE_SITEMAP_COMPRESS', 'false');
       /**
        * Option for change frequency of products
        */
       define('GOOGLE_SITEMAP_PROD_CHANGE_FREQ', 'weekly');
       /**
        * Option for change frequency of categories
        */
       define('GOOGLE_SITEMAP_CAT_CHANGE_FREQ', 'weekly');
       /**
        * Carried over from application_top.php for compatibility
        */
       define('GOOGLE_SITEMAP_MAN_CHANGE_FREQ', 'weekly');
       /**
        * Carried over from application_top.php for compatibility
        */
       define('GOOGLE_SITEMAP_SPECIALS_CHANGE_FREQ', 'weekly');
       /**
        * Carried over from application_top.php for compatibility
        */
include_once 'includes/application_top.php';

require_once('googlesitemap/sitemap.class.php');

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

$submit = true;

echo '<pre>';
if ($google->GenerateProductSitemap()){
       echo 'Generated Google Product Sitemap Successfully' . "\n\n";
} else {
       $submit = false;
       echo 'ERROR: Google Product Sitemap Generation FAILED!' . "\n\n";
}

if ($google->GenerateCategorySitemap()){
       echo 'Generated Google Category Sitemap Successfully' . "\n\n";
} else {
       $submit = false;
       echo 'ERROR: Google Category Sitemap Generation FAILED!' . "\n\n";
}

$showManufacturers = true;
if ($google->GenerateManufacturerSitemap()){
       echo 'Generated Google Manufacturers Sitemap Successfully' . "\n\n";
} else {
 $manufacturers_query = tep_db_query("select manufacturers_id from " . TABLE_MANUFACTURERS . " limit 1");
 if (tep_db_num_rows($manufacturers_query) > 0)
 {
       $submit = false;
         echo 'ERROR: Google Manufacturers Sitemap Generation FAILED!' . "\n\n";
 }
 else 
 {
       $showManufacturers = false;
         echo 'Google Sitemap Manufacturers not generated - no Manufacturers found!' . "\n\n";
 } 
}

$showSpecials = true;
if ($google->GenerateSpecialsSitemap()){
       echo 'Generated Google Specials Sitemap Successfully' . "\n\n";
} else {
 $specials_query = tep_db_query("select p.products_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' limit 1");
 if (tep_db_num_rows($specials_query) > 0)
 {
         $submit = false;
         echo 'ERROR: Google Specials Sitemap Generation FAILED!' . "\n\n";
 }
 else 
 {
       $showSpecials = false;
         echo 'Google Sitemap Specials not generated - no specials found!' . "\n\n";
 } 
}

if ($google->GenerateSitemapIndex()){
       echo 'Generated Google Sitemap Index Successfully' . "\n\n";
} else {
       $submit = false;
       echo 'ERROR: Google Sitemap Index Generation FAILED!' . "\n\n";
}

if ($submit){
       echo 'CONGRATULATIONS! All files generated successfully.' . "\n\n";
       echo 'If you have not already submitted the sitemap index to Google click the link below.' . "\n";
       echo 'Before you do I HIGHLY recommend that you view the XML files to make sure the data is correct.' . "\n\n";
       echo $google->GenerateSubmitURL() . "\n\n";
       echo 'For your convenience here is the CRON command for your site:' . "\n";
       echo 'php ' . dirname($_SERVER['SCRIPT_FILENAME']) . '/index.php' . "\n\n";
       echo 'Here is your sitemap index: ' . $google->base_url . 'sitemapindex.xml' . "\n";
       echo 'Here is your product sitemap: ' . $google->base_url . 'sitemapproducts.xml' . "\n";
       echo 'Here is your category sitemap: ' . $google->base_url . 'sitemapcategories.xml' . "\n";

 if ($showManufacturers)
       echo 'Here is your manufacturers sitemap: ' . $google->base_url . 'sitemapmanufacturers.xml' . "\n";

 if ($showSpecials)
         echo 'Here is your specials sitemap: ' . $google->base_url . 'sitemapspecials.xml' . "\n";
} else {
       print_r($google->debug);
}

echo '</pre>';
include_once 'includes/application_top.php';
?>

 

and sitemap.class.php:

 

<?php
/**
* Google XML Sitemap Feed
*
* The Google 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 specification delineated 
* by Google. 
* @package Google-XML-Sitemap-Feed
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 1.0
* @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers
* @link http://www.google.com/webmasters/sitemaps/docs/en/about.html About Google Sitemap 
* @copyright Copyright 2005, Bobby Easland 
* @author Bobby Easland 
* @filesource
*/

/**
* MySQL_Database Class
*
* The MySQL_Database class provides abstraction so the databaes can be accessed
* without having to use tep API functions. This class has minimal error handling
* so make sure your code is tight!
* @package Google-XML-Sitemap-Feed
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 1.1
* @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers
* @copyright Copyright 2005, Bobby Easland 
* @author Bobby Easland 
*/

/**
* Google Sitemap Base Class
*
* The MySQL_Database class provides abstraction so the databaes can be accessed
* @package Google-XML-Sitemap-Feed
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 1.2
* @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers
* @link http://www.google.com/webmasters/sitemaps/docs/en/about.html About Google Sitemap
* @copyright Copyright 2005, Bobby Easland 
* @author Bobby Easland 
*/
class GoogleSitemap{
       /**
       * $filename is the base name of the feeds (i.e. - 'sitemap')
       * @var string
       */
       var $filename;
       /**
       * $savepath is the path where the feeds will be saved - store root
       * @var string
       */
       var $savepath;
       /**
       * $base_url is the URL for the catalog
       * @var string
       */
       var $base_url;
       /**
       * $debug holds all the debug data
       * @var array
       */
       var $debug;


/**
* GoogleSitemap class constructor 
* @author Bobby Easland 
* @version 1.0
* @param string $host Database host setting (i.e. - localhost)
* @param string $user Database user
* @param string $db Database name
* @param string $pass Database password
*/     
       function GoogleSitemap(){
               $this->filename = "sitemap";
               $this->savepath = DIR_FS_CATALOG;
               $this->base_url = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
               $this->debug = array();
       } # end class constructor

/**
* Function to save the sitemap data to file as either XML or XML.GZ format
* @author Bobby Easland 
* @version 1.1
* @param string $data XML data
* @param string $type Feed type (index, products, categories)
* @return boolean
*/     
       function SaveFile($data, $type){
               $filename = $this->savepath . $this->filename . $type;                  
               $compress = defined('GOOGLE_SITEMAP_COMPRESS') ? GOOGLE_SITEMAP_COMPRESS : 'false';
               if ($type == 'index') $compress = 'false';
               switch($compress){
                       case 'true':
                               $filename .= '.xml.gz';
                               if ($gz = gzopen($filename,'wb9')){
                                       gzwrite($gz, $data);
                                       gzclose($gz);
                                       $this->debug['SAVE_FILE_COMPRESS'][] = array('file' => $filename, 'status' => 'success', 'file_exists' => 'true');
                                       return true;
                               } else {
                                       $file_check = file_exists($filename) ? 'true' : 'false';
                                       $this->debug['SAVE_FILE_COMPRESS'][] = array('file' => $filename, 'status' => 'failure', 'file_exists' => $file_check);
                                       return false;
                               }
                               break;
                       default:
                               $filename .= '.xml';
                               if ($fp = fopen($filename, 'w+')){
                                        echo 'Write '.$filename.'<br>';
                                       fwrite($fp, $data);
                                       fclose($fp);
                                       $this->debug['SAVE_FILE_XML'][] = array('file' => $filename, 'status' => 'success', 'file_exists' => 'true');
                                       return true;
                               } else {
                                       $file_check = file_exists($filename) ? 'true' : 'false';
                                       $this->debug['SAVE_FILE_XML'][] = array('file' => $filename, 'status' => 'failure', 'file_exists' => $file_check);
                                       return false;
                               }
                               break;
               } # end switch 
       } # end function

/**
* Function to compress a normal file
* @author Bobby Easland 
* @version 1.0
* @param string $file
* @return boolean
*/     
       function CompressFile($file){
               $source = $this->savepath . $file . '.xml';
               $filename = $this->savepath . $file . '.xml.gz';
               $error_encountered = false;
               if( $gz_out = gzopen($filename, 'wb9') ){
                       if($fp_in = fopen($source,'rb')){
                               while(!feof($fp_in)) gzwrite($gz_out, fread($fp_in, 1024*512));
                                       fclose($fp_in);

                       } else {
                               $error_encountered = true;
                       }
                       gzclose($gz_out);
               } else {
                       $error_encountered = true;
               }
               if($error_encountered){
                       return false;
               } else {
                       return true;    
               }
       } # end function

/**
* Function to generate sitemap file from data
* @author Bobby Easland 
* @version 1.0
* @param array $data
* @param string $file
* @return boolean
*/     
       function GenerateSitemap($data, $file){
               $content = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
               $content = '<?xml-stylesheet type="text/xsl" href="gss.xsl"?>' . "\n";
               $content .= '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">' . "\n";
               foreach ($data as $url){
                       $content .= "\t" . '<url>' . "\n";
                       $content .= "\t\t" . '<loc>'.$url['loc'].'</loc>' . "\n";
                       $content .= "\t\t" . '<lastmod>'.$url['lastmod'].'</lastmod>' . "\n";
                       $content .= "\t\t" . '<changefreq>'.$url['changefreq'].'</changefreq>' . "\n";
                       $content .= "\t\t" . '<priority>'.$url['priority'].'</priority>' . "\n";
                       $content .= "\t" . '</url>' . "\n";
               } # end foreach
               $content .= '</urlset>';
               return $this->SaveFile($content, $file);
       } # end function

/**
* Function to generate sitemap index file 
* @author Bobby Easland 
* @version 1.1
* @return boolean
*/     
       function GenerateSitemapIndex(){
               $content = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
               $content = '<?xml-stylesheet type="text/xsl" href="gss.xsl"?>' . "\n"; //human readable
               $content .= '<sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.84">' . "\n";         
               $pattern = defined('GOOGLE_SITEMAP_COMPRESS')
                                        ?      GOOGLE_SITEMAP_COMPRESS == 'true'
                                                       ?       "{sitemap*.xml.gz}"
                                                       :       "{sitemap*.xml}"
                                        :      "{sitemap*.xml}";
               foreach ( glob($this->savepath . $pattern, GLOB_BRACE) as $filename ) {
                  if ( eregi('index', $filename) ) continue;
                  $content .= "\t" . '<sitemap>' . "\n";
                  $content .= "\t\t" . '<loc>'.$this->base_url . basename($filename).'</loc>' . "\n";
                  $content .= "\t\t" . '<lastmod>'.date ("Y-m-d", filemtime($filename)).'</lastmod>' . "\n";
                  $content .= "\t" . '</sitemap>' . "\n";                              
               } # end foreach
               $content .= '</sitemapindex>';
               return $this->SaveFile($content, 'index');
       } # end function

/**
* Function to generate product sitemap data
* @author Bobby Easland 
* @version 1.1
* @return boolean
*/     
       function GenerateProductSitemap(){
               $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";
               if ( $products_query = tep_db_query($sql) ){
                       $this->debug['QUERY']['PRODUCTS']['STATUS'] = 'success';
                       $this->debug['QUERY']['PRODUCTS']['NUM_ROWS'] = tep_db_num_rows($products_query);
                       $container = array();
                       $number = 0;
                       $top = 0;
                       while( $result = tep_db_fetch_array($products_query) ){
                               $top = max($top, $result['products_ordered']);
                               $location = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], 'NONSSL', false);
                               $lastmod = tep_not_null($result['last_mod']) ? $result['last_mod'] : $result['date_added'];
                               $changefreq = GOOGLE_SITEMAP_PROD_CHANGE_FREQ;
                               $ratio = $top > 0 ? $result['products_ordered']/$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
                       tep_db_free_result($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

/**
* Funciton to generate category sitemap data
* @author Bobby Easland 
* @version 1.1
* @return boolean
*/     
       function GenerateCategorySitemap(){
               $sql = "SELECT categories_id as cID, date_added, last_modified as last_mod 
                               FROM " . TABLE_CATEGORIES . " 
                               ORDER BY parent_id ASC, sort_order ASC, categories_id ASC";
               if ( $categories_query = tep_db_query($sql) ){
                       $this->debug['QUERY']['CATEOGRY']['STATUS'] = 'success';
                       $this->debug['QUERY']['CATEOGRY']['NUM_ROWS'] = tep_db_num_rows($categories_query);
                       $container = array();
                       $number = 0;
                       while( $result = tep_db_fetch_array($categories_query) ){
                               $location =tep_href_link(FILENAME_DEFAULT, 'cPath=' . $this->GetFullcPath($result['cID']), 'NONSSL', false);
                               $lastmod = tep_not_null($result['last_mod']) ? $result['last_mod'] : $result['date_added'];
                               $changefreq = GOOGLE_SITEMAP_CAT_CHANGE_FREQ;
                               $priority = .5; 

                               $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 ? 'categories' : 'categories' . $number;
                                       $this->GenerateSitemap($container, $type);
                                       $container = array();
                                       $number++;
                               }
                       } # end while
                       tep_db_free_result($categories_query);                  
                       if ( sizeof($container) > 1 ) {
                               $type = $number == 0 ? 'categories' : 'categories' . $number;
                               return $this->GenerateSitemap($container, $type);
                       } # end if                      
               } else {
                       $this->debug['QUERY']['CATEOGRY']['STATUS'] = 'false';
                       $this->debug['QUERY']['CATEOGRY']['NUM_ROWS'] = '0';
               }
       } # end function

/**
* Funciton to generate manufacturer sitemap data
* @author Jack_mcs from Bobbys code
* @version 1.1
* @return boolean
*/
       function GenerateManufacturerSitemap(){
               $sql = "SELECT manufacturers_id as mID, date_added, last_modified as last_mod, manufacturers_name
                               FROM " . TABLE_MANUFACTURERS . " order by manufacturers_name DESC";

               if ( $manufacturers_query = tep_db_query($sql) ){
                       $this->debug['QUERY']['MANUFACTURERS']['STATUS'] = 'success';
                       $this->debug['QUERY']['MANUFACTURERS']['NUM_ROWS'] = tep_db_num_rows($manufacturers_query);
                       $container = array();
                       $number = 0;
                       while( $result = tep_db_fetch_array($manufacturers_query) ){
                               $location = tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $result['mID'], 'NONSSL', false);
                               $lastmod = tep_not_null($result['last_mod']) ? $result['last_mod'] : $result['date_added'];
                               $changefreq = GOOGLE_SITEMAP_MAN_CHANGE_FREQ;
                               $priority = .5;

                               $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 ? 'manufacturers' : 'manufacturers' . $number;
                                       $this->GenerateSitemap($container, $type);
                                       $container = array();
                                       $number++;
                               }
                       } # end while
                       tep_db_free_result($manufacturers_query);
                       if ( sizeof($container) > 1 ) {
                               $type = $number == 0 ? 'manufacturers' : 'manufacturers' . $number;
                               return $this->GenerateSitemap($container, $type);
                       } # end if                      
               } else {
                       $this->debug['QUERY']['MANUFACTURERS']['STATUS'] = 'false';
                       $this->debug['QUERY']['MANUFACTURERS']['NUM_ROWS'] = '0';
               }
       } # end function

/**
* Funciton to generate manufacturer sitemap data
* @author Jack_mcs from Bobbys code
* @version 1.1
* @return boolean
*/
       function GenerateSpecialsSitemap(){
               $sql = "SELECT p.products_id as pID, s.specials_date_added as date_added, s.specials_last_modified as last_mod, p.products_ordered
                               FROM " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id left join " . TABLE_SPECIALS . " s on pd.products_id = s.products_id
                               where p.products_status = '1' and s.status = '1' order by s.specials_date_added desc ";
               if ( $products_query = tep_db_query($sql) ){
                       $this->debug['QUERY']['SPECIALS']['STATUS'] = 'success';
                       $this->debug['QUERY']['SPECIALS']['NUM_ROWS'] = tep_db_num_rows($products_query);
                       $container = array();
                       $number = 0;
                       $top = 0;
                       while( $result = tep_db_fetch_array($products_query) ){
                               $top = max($top, $result['products_ordered']);
                               $location = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], 'NONSSL', false);
                               $lastmod = tep_not_null($result['last_mod']) ? $result['last_mod'] : $result['date_added'];
                               $changefreq = GOOGLE_SITEMAP_SPECIALS_CHANGE_FREQ;
                               $ratio = $top > 0 ? $result['products_ordered']/$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 ? 'specials' : 'specials' . $number;
                                       $this->GenerateSitemap($container, $type);
                                       $container = array();
                                       $number++;
                               }
                       } # end while
                       tep_db_free_result($products_query);                    
                       if ( sizeof($container) > 1 ) {
                               $type = $number == 0 ? 'specials' : 'specials' . $number;
                               return $this->GenerateSitemap($container, $type);
                       } # end if                      
               } else {
                       $this->debug['QUERY']['SPECIALS']['STATUS'] = 'false';
                       $this->debug['QUERY']['SPECIALS']['NUM_ROWS'] = '0';
               }
       } # end function

/**
* Function to retrieve full cPath from category ID 
* @author Bobby Easland 
* @version 1.0
* @param mixed $cID Could contain cPath or single category_id
* @return string Full cPath string
*/     
       function GetFullcPath($cID){
               if ( ereg('_', $cID) ){
                       return $cID;
               } else {
                       $c = array();
                       $this->GetParentCategories($c, $cID);
                       $c = array_reverse($c);
                       $c[] = $cID;
                       $cID = sizeof($c) > 1 ? implode('_', $c) : $cID;
                       return $cID;
               }
       } # end function

/**
* Recursion function to retrieve parent categories from category ID 
* @author Bobby Easland 
* @version 1.0
* @param mixed $categories Passed by reference
* @param integer $categories_id
*/     
       function GetParentCategories(&$categories, $categories_id) {
               $sql = "SELECT parent_id 
                               FROM " . TABLE_CATEGORIES . " 
                               WHERE categories_id='" . (int)$categories_id . "'";
               $parent_categories_query = tep_db_query($sql);
               while ($parent_categories = tep_db_fetch_array($parent_categories_query)) {
                       if ($parent_categories['parent_id'] == 0) return true;
                       $categories[sizeof($categories)] = $parent_categories['parent_id'];
                       if ($parent_categories['parent_id'] != $categories_id) {
                               $this->GetParentCategories($categories, $parent_categories['parent_id']);
                       }
               }
       } # end function

/**
* Utility function to read and return the contents of a GZ formatted file
* @author Bobby Easland 
* @version 1.0
* @param string $file File to open
* @return string
*/     
       function ReadGZ( $file ){
               $file = $this->savepath . $file;
               $lines = gzfile($file);
               return implode('', $lines);
       } # end function

/**
* Utility function to generate the submit URL 
* @author Bobby Easland 
* @version 1.0
* @return string
*/     
       function GenerateSubmitURL(){
               $url = urlencode($this->base_url . 'sitemapindex.xml');
               return htmlspecialchars(utf8_encode('http://www.google.com/webmasters/sitemaps/ping?sitemap=' . $url));
       } # end function
} #  end class
?>

Edited by bhbilbao

Share this post


Link to post
Share on other sites

what are the requirements to generate the products sitemaps?

I also have HeaderTagasSeo contrib and Robert´s USU5 PRO.

The latter isn't compatible with this conribution. A special contribution was upload to allow that contribution to work correctly. It is named similar to this one but I don't recall the exact name. You can search the forums or look back through this thread to find a post about it. For this contribution, and just in general actually, I recommend using Ultimate SEO V2.2d. It will work flawlesly with this, and all other, contributions. As for the requirements for the products, there isn't anything special needed. Google had a limit on the size of the map file it will accept and when that size is reached in the code, the current file is closed and a new one started. But that is all internal and doesn't require anything from you.

Share this post


Link to post
Share on other sites

There shouldn't be any reason why it won't work with 2.3 since it doesn't change any of the code that is different in that version.

 

Jack, this is just some feedback on this add on with 2.3.1. Seeing what you wrote here I installed this on an "in progress" 2.3.1 shop.

 

It's working fine, no problems that I can see after running it a few days. I have a cron job set up for that also and it's run fine as well.

 

This is with Ultimate SEO V 2.2d-11 installed on the same shop.

At this point I am only generating the index, products and categories xml sitemaps.


I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Share this post


Link to post
Share on other sites

Jack, this is just some feedback on this add on with 2.3.1. Seeing what you wrote here I installed this on an "in progress" 2.3.1 shop.

 

It's working fine, no problems that I can see after running it a few days. I have a cron job set up for that also and it's run fine as well.

 

This is with Ultimate SEO V 2.2d-11 installed on the same shop.

At this point I am only generating the index, products and categories xml sitemaps.

Thanks for posting your results. I'm sure it will help others and I will add a link to the 2.3 Addon section now that I know for sure.

Share this post


Link to post
Share on other sites

Jack, are you sure that the newly posted link is correct? I believe that you wanted to mention this one instead: http://addons.oscommerce.com/info/6583

Yes, you are correct. Thanks for pointing that out. I've made that change.

Share this post


Link to post
Share on other sites

Edit: Ninja'd.

 

Regards

Jim

Edited by kymation

See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×