Google Sitemap Generator With Manufacturers

I have been thinking for quite some time now that if one has products from various manufacturers, wouldn’t one want to get the word out that they carry products from that manufacturer?



Well, I finally got around to implementing the code in the generator so for those of you that want to let the search engines know your manufacturers…here it is. This is the entire code and the changes are in [COLOR=“Blue”]BLUE[/COLOR].






```php
//=======================================================================

// File: GOOGLE_SITEMAP.PHP

// Description: Google Sitemap Generator [COLOR=“Blue”]With Manufacturers[/COLOR].

// Created: [COLOR=“Blue”]07-26-2008[/COLOR]

// Ver: $Id: google_sitemap.php [COLOR=“Blue”]3 07-26-2008[/COLOR] 00:0:00Z lsb $

//

// Copyright 2006 (c) RENS Management, LLC. All rights reserved.

//========================================================================



if ( !defined(‘IN_CSCART’) ) { die(‘Access denied’); }



$products=$categories=[COLOR=“Blue”]$manufacturers=[/COLOR]array();

$categories_all=db_get_array(“SELECT category_id FROM $db_tables[categories] WHERE membership_id=0 && avail=‘Y’”);

$products_all=db_get_array(“SELECT product_id FROM $db_tables[products] WHERE avail=‘Y’”);

[COLOR=“Blue”]$manufacturers_all=db_get_array(“SELECT manufacturer_id FROM $db_tables[manufacturers] WHERE avail=‘Y’”);[/COLOR]

while (list(, $cats) = each($categories_all)) $categories[]=$cats[‘category_id’];

while (list(, $items) = each($products_all)) $products[]=$items[‘product_id’];

[COLOR=“Blue”]while (list(, $mfrs) = each($manufacturers_all)) $manufacturers[]=$mfrs[‘manufacturer_id’];[/COLOR]



header(“Content-Type: text/xml;charset=utf-8”);

$lastmod = date(“Y-m-d”, time());

$siteurl = utf8_encode(htmlentities(“$http_location”));

echo <<


http://www.w3.org/2001/XMLSchema-instance”

xsi:schemaLocation=“www.sitemaps.org - /schemas/sitemap/0.9/

http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd

xmlns=“www.sitemaps.org - /schemas/sitemap/0.9/”>



$siteurl

$lastmod

daily

1.0

\n

START;



// process categories

foreach ($categories as $category) {

$link = utf8_encode(htmlentities(“$http_location/$index_script?$target_name=categories&category_id=$category”));

fn_convert_php_urls($link);

echo <<


$siteurl/$link

$lastmod

daily

0.5

\n

LINKS;

}



[COLOR=“Blue”]// process manufacturers

foreach ($manufacturers as $manufacturer) {

$link = utf8_encode(htmlentities(“$http_location/$index_script?$target_name=manufacturers&manufacturer_id=$manufacturer”));

fn_convert_php_urls($link);

echo <<


$siteurl/$link

$lastmod

daily

0.5

\n

LINKS;

}[/COLOR]



// process products

foreach ($products as $product) {

$link = utf8_encode(htmlentities(“$http_location/$index_script?$target_name=products&product_id=$product”));

fn_convert_php_urls($link);

echo <<


$siteurl/$link

$lastmod

daily

0.5

\n

LINKS;

}



echo <<




END;

exit;

?> ```

Implemented and tested. This works very well. Thanks!

Does this need to be installed or does it just go in the root directory?

Hi , please could you give me the post url to put on this hack step by step o complete the post cut and past to have directly here the complete isssue for sitemap + manufacturer.:wink:

would this work in 1.3.3?



thanks

[quote name=‘smoked1’]Does this need to be installed or does it just go in the root directory?[/QUOTE]



If you already have the original generator set up, then you just need to add this file to the root/include/admin and root/include/customer folder.




[quote name=‘mototropic@gmail.com’]Hi , please could you give me the post url to put on this hack step by step o complete the post cut and past to have directly here the complete isssue for sitemap + manufacturer.[/QUOTE]



Follow the instructions here [url]http://forum.cs-cart.com/showthread.php?t=4585[/url] but use this file instead of the original.




[quote name=‘zoom4267’]would this work in 1.3.3?



thanks[/QUOTE]



I think there were some minor changes since that version but you should be able to convert it back. Let me know if you need help.

Here’s an extension of Tool Outfitters mod to the Google Sitemap. This adds cms pages too, although it’s not smart enough to supress pages that are hidden. Also, this will only work for those of you using SEO Names and mod-rewrite. For reference, I’m running 1.3.5-SP3



Best,



Tim


```php
//================================================== =====================

// File: GOOGLE_SITEMAP.PHP

// Description: Google Sitemap Generator with CMS Pages and Manufacturers. FOR SEO NAMES ONLY

// Created: 2006-10-12

// Ver: $Id: google_sitemap.php 4 2008-10-29 00:0:00Z lsb $

//

// Copyright 2006 (c) RENS Management, LLC. All rights reserved.

//================================================== ======================



if ( !defined(‘IN_CSCART’) ) { die(‘Access denied’); }



$products=$categories=$seo_names=$manufacturers=array();

$categories_all=db_get_array(“SELECT category_id FROM $db_tables[categories] WHERE membership_id=0 && avail=‘Y’”);

$products_all=db_get_array(“SELECT product_id FROM $db_tables[products] WHERE avail=‘Y’”);

$seo_names_all=db_get_array(“SELECT name FROM $db_tables[seo_names] WHERE type=‘a’”);

$manufacturers_all=db_get_array(“SELECT manufacturer_id FROM $db_tables[manufacturers] WHERE avail=‘Y’”);

while (list(, $cats) = each($categories_all)) $categories[]=$cats[‘category_id’];

while (list(, $items) = each($products_all)) $products[]=$items[‘product_id’];

while (list(, $cms) = each($seo_names_all)) $seo_names[]=$cms[‘name’];

while (list(, $mfrs) = each($manufacturers_all)) $manufacturers[]=$mfrs[‘manufacturer_id’];





header(“Content-Type: text/xml;charset=utf-8”);

$lastmod = date(“Y-m-d”, time());

$siteurl = utf8_encode(htmlentities(“$http_location”));

echo <<






$siteurl

$lastmod

daily

1.0

\n

START;



// process categories

foreach ($categories as $category) {

$link = utf8_encode(htmlentities(“$http_location/$index_script?$target_name=categories&category_id= $category”));

fn_convert_php_urls($link);

echo <<


$siteurl/$link

$lastmod

daily

0.5

\n

LINKS;

}



// process products

foreach ($products as $product) {

$link = utf8_encode(htmlentities(“$http_location/$index_script?$target_name=products&product_id=$product”));

fn_convert_php_urls($link);

echo <<


$siteurl/$link

$lastmod

daily

0.5

\n

LINKS;

}





// process cms pages

foreach ($seo_names as $seo_name) {

//$link = utf8_encode(htmlentities(“$http_location/$index_script?$target_name=products&product_id=$seo_name”));

fn_convert_php_urls($link);

echo <<


$siteurl/$seo_name.html

$lastmod

daily

0.5

\n

LINKS;

}



// process manufacturers

foreach ($manufacturers as $manufacturer) {

$link = utf8_encode(htmlentities(“$http_location/$index_script?$target_name=manufacturers&manufacturer_id=$manufacturer”));

fn_convert_php_urls($link);

echo <<


$siteurl/$link

$lastmod

daily

0.5

\n

LINKS;

}



echo <<




END;

exit;

?>

```