Hi David
I was wondering, would it be possible to create a separate 'mapped products only' sitemap?
eg. sitemap-pm.php
thanks
Phil
Thanks David
Works great, just came accross a small problem though..
Your Sitemap contains too many URLs. Please create multiple Sitemaps with up to 50000 URLs each and submit all Sitemaps.
is there a solution for this?
Thanks
Phil
Hello Phil,
Sure - here's a version that will initially return a sitemap index with links to individual sitemaps of up to 50,000 products (just like the main sitemap.php script)...
<?php
require("includes/common.php");
header("Content-Type: text/xml");
print "<?xml version='1.0' encoding='UTF-8'?>";
$sitemapBaseHREF = "http".(isset($_SERVER["HTTPS"])&&$_SERVER["HTTPS"]?"s":"")."://".$_SERVER["HTTP_HOST"].$config_baseHREF;
$start = (isset($_GET["start"])?intval($_GET["start"]):FALSE);
$limit = 50000;
if ($start !== FALSE)
{
print "<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>";
$sql = "SELECT name FROM `".$config_databaseTablePrefix."productsmap` ORDER BY id LIMIT ".$start.",".$limit;
$link = mysqli_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword,$config_databaseName);
mysqli_set_charset($link,"utf8");
mysqli_real_query($link,$sql);
$result = mysqli_use_result($link);
while($row = mysqli_fetch_assoc($result))
{
$row["normalised_name"] = tapestry_normalise($row["name"]);
print "<url>";
$sitemapHREF = tapestry_productHREF($row);
print "<loc>".$sitemapBaseHREF.$sitemapHREF."</loc>";
print "</url>";
}
print "</urlset>";
}
else
{
$sql = "SELECT COUNT(*) AS numProducts FROM `".$config_databaseTablePrefix."productsmap`";
database_querySelect($sql,$rows);
$numProducts = $rows[0]["numProducts"];
print "<sitemapindex xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>";
$start = 0;
while($start < $numProducts)
{
print "<sitemap>";
$sitemapHREF = "sitemap-pm.php?start=".$start;
print "<loc>".$sitemapBaseHREF.$sitemapHREF."</loc>";
print "</sitemap>";
$start += $limit;
}
print "</sitemapindex>";
}
?>
Cheers,
David.
--
PriceTapestry.com
Hello Phil,
Sure - have a go with;
<?php
require("includes/common.php");
header("Content-Type: text/xml");
print "<?xml version='1.0' encoding='UTF-8'?>";
print "<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>";
$sql = "SELECT name FROM `".$config_databaseTablePrefix."productsmap`";
$link = mysqli_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword,$config_databaseName);
mysqli_set_charset($link,"utf8");
mysqli_real_query($link,$sql);
$result = mysqli_use_result($link);
$sitemapBaseHREF = "http".(isset($_SERVER["HTTPS"])&&$_SERVER["HTTPS"]?"s":"")."://".$_SERVER["HTTP_HOST"];
while($row = mysqli_fetch_assoc($result))
{
$row["normalised_name"] = tapestry_normalise($row["name"]);
print "<url>";
$sitemapHREF = tapestry_productHREF($row);
print "<loc>".$sitemapBaseHREF.$sitemapHREF."</loc>";
print "</url>";
}
print "</urlset>";
?>
Cheers,
David.
--
PriceTapestry.com