JavaScript Editor Ajax software     Free javascripts 



Main Page

you will create a duplicate shopping cart page per product. Create the following
robots.php
file in your
seophp
folder. This file is already mapped to handle
robots.txt
requests using a
mod_rewrite rule:
<?php
// set propert content type
header(‘Content-type: text/plain’);
// include config file
require_once ‘include/config.inc.php’;
// load database tools
require_once(‘include/database_tools.inc.php’);
// load the URL factory
require_once ‘include/url_factory.inc.php’;
// this query returns product_id and secondary_category_id data which needs to be
// excluded using robots.txt
$q = ‘SELECT products.*, ‘ .
‘product_categories.category_id AS secondary_category_id, ‘ .
‘categories.name AS secondary_category_name ‘ .
‘FROM products LEFT JOIN product_categories ‘ .
‘ON (product_categories.product_id = products.id) ‘ .
‘LEFT JOIN categories ‘ .
‘ON (product_categories.category_id = categories.id) ‘ .
‘WHERE products.primary_category_id <> product_categories.category_id’;
// get a database connection
$db_link = DatabaseTools::getConnection();
// execute the query
$query_results = mysql_query($q);
// close database connection
DatabaseTools::closeConnection($db_link);
// create an associative array with the results
$rows = array();
while ($result = mysql_fetch_assoc($query_results)) {
$rows[] = $result;
}
// User agent
echo “User-agent: * \r\n”;
// display the links that need to be excluded
foreach ($rows as $row)
{
// get the category and product IDs
$product_id = $row[‘id’];
$category_id = $row[‘secondary_category_id’];
$product_name = $row[‘name’];
$category_name = $row[‘secondary_category_name’];
278
Chapter 14: Case Study: Building an E-Commerce Store
c14.qxd:c14 10:46 278


JavaScript Editor Ajax software     Free javascripts