Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Google Sitemap Generator With Manufacturers Rate Topic   - - - - -

 
  • The Tool
  • Been Here Way Too Long Member
  • Members
  • Join Date: 30-Mar 07
  • 3967 posts

Posted 26 July 2008 - 08:21 AM #1

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



<?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 <<<START
<?xml version='1.0' encoding='UTF-8'?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
         http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
         xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <url>
      <loc>$siteurl</loc>
      <lastmod>$lastmod</lastmod>
      <changefreq>daily</changefreq>
      <priority>1.0</priority>
   </url>\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 <<<LINKS
   <url>
      <loc>$siteurl/$link</loc>
      <lastmod>$lastmod</lastmod>
      <changefreq>daily</changefreq>
      <priority>0.5</priority>
   </url>\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 <<<LINKS
   <url>
      <loc>$siteurl/$link</loc>
      <lastmod>$lastmod</lastmod>
      <changefreq>daily</changefreq>
      <priority>0.5</priority>
   </url>\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 <<<LINKS
   <url>
      <loc>$siteurl/$link</loc>
      <lastmod>$lastmod</lastmod>
      <changefreq>daily</changefreq>
      <priority>0.5</priority>
   </url>\n
LINKS;
}

echo <<<END

</urlset>
END;
exit;
?>


 
  • pbradish
  • Senior Member
  • Members
  • Join Date: 03-Apr 08
  • 119 posts

Posted 31 July 2008 - 09:22 PM #2

Implemented and tested. This works very well. Thanks!

 
  • smoked1
  • Senior Member
  • Members
  • Join Date: 19-May 06
  • 178 posts

Posted 02 August 2008 - 09:27 AM #3

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

 

Posted 02 August 2008 - 10:24 AM #4

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

 
  • zoom4267
  • Senior Member
  • Members
  • Join Date: 27-May 06
  • 847 posts

Posted 02 August 2008 - 05:47 PM #5

would this work in 1.3.3?

thanks
Lisa

http://www.skytopdesigns.com Web designs and Development

 
  • The Tool
  • Been Here Way Too Long Member
  • Members
  • Join Date: 30-Mar 07
  • 3967 posts

Posted 04 August 2008 - 02:07 PM #6

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


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.


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.


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


would this work in 1.3.3?

thanks


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.

 
  • bsweezey
  • Junior Member
  • Members
  • Join Date: 22-Oct 08
  • 14 posts

Posted 29 October 2008 - 06:16 PM #7

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 <<<START
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<url>
<loc>$siteurl</loc>
<lastmod>$lastmod</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>\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 <<<LINKS
<url>
<loc>$siteurl/$link</loc>
<lastmod>$lastmod</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>\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 <<<LINKS
<url>
<loc>$siteurl/$link</loc>
<lastmod>$lastmod</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>\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 <<<LINKS
<url>
<loc>$siteurl/$seo_name.html</loc>
<lastmod>$lastmod</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>\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 <<<LINKS
   <url>
      <loc>$siteurl/$link</loc>
      <lastmod>$lastmod</lastmod>
      <changefreq>daily</changefreq>
      <priority>0.5</priority>
   </url>\n
LINKS;
}

echo <<<END

</urlset>
END;
exit;
?>