Hi David,
Is it possible to make a copy of search.php or whatever file needed and change it so it only give results on mapped products but keep unmapped products in database?
Second question
When there are mapped products is it possible that it always shows up even when there's no product at that time but show without price ofcourse.
I use updated 1109A and 12.10B
Leo
Hi leo,
For a niche site it should be practical to construct an IN clause and patch it into the search SQL via the $priceWhere variable (in the same way that sidebar filters do). To try this, look for the following code in search.php: (line 34 in 11/09A, line 49 in 12/10B)
if ($q)
...and REPLACE with:
$sql = "SELECT name FROM `".$config_databaseTablePrefix."productsmap`";
database_querySelect($sql,$rows);
$ins = array();
foreach($rows as $row)
{
$ins[] = "'".database_safe($row["name"])."'";
}
$in = implode(",",$ins);
$priceWhere .= " AND name IN (".$in.") ";
if ($q)
Regarding products that are mapped but not currently in the database, one way to incorporate these would be a post-import process that creates dummy product records with your description and just a "More Information" link displayed in the search results; together with similar modifications to the product page HTML to handle the no-merchant case. This could be "plumbed in" at the point where reviews are back-filled into the products table as this happens after every import process. To try this, look for the following code in includes/admin.php: (line 466 in 11/09A, line 532 in 12/10B)
$sql = "UPDATE `".$config_databaseTablePrefix."products` SET rating='0',reviews='0'";
...and REPLACE with:
$sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE merchant=''";
database_queryModify($sql,$result);
$sql = "SELECT name,description FROM `".$config_databaseTablePrefix."productsmap`";
database_querySelect($sql,$rows);
foreach($rows as $row)
{
$sql = "SELECT id FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($row["name"])."' LIMIT 1";
if (!database_querySelect($sql,$result))
{
$sql = "INSERT INTO `".$config_databaseTablePrefix."products` SET
filename='',
merchant='',
name='".database_safe($row["name"])."',
search_name='".database_safe(tapestry_search($row["name"]))."',
normalised_name='".database_safe(tapestry_normalise($row["name"]))."',
description='".database_safe($row["description"])."',
dupe_hash='".md5($row["name"])."'";
}
database_queryModify($sql,$result);
}
$sql = "UPDATE `".$config_databaseTablePrefix."products` SET rating='0',reviews='0'";
With that in place, modify html/searchresults.php to handle the null merchant case; look for the following code at line 24:
<?php if ($product["numMerchants"] > 1): ?>
...and REPLACE with:
<?php if ($product["merchant"]==""): ?>
<span class='nobr'><a href='<?php print $product["productHREF"]; ?>'><?php print translate("More Information"); ?></a></span>
<?php elseif ($product["numMerchants"] > 1): ?>
Next, in html/product.php the first stage is to suppress the the main product price display section. To do this, look for the following code at line 15:
<table border='0' cellpadding='0' cellspacing='0'>
....and REPLACE with:
<?php if ($mainProduct["merchant"] != ""): ?>
<table border='0' cellpadding='0' cellspacing='0'>
...and then the following code at line 38:
</table>
...and REPLACE with:
</table>
<?php endif; ?>
Finally, in products.php to suppress the price comparison table (and optionally display an alternative message) look for the following code at line 118:
if (isset($prices)) require("html/prices.php");
...and REPLACE with:
if (isset($prices) && ($product["products"][0]["merchant"] != ""))
{
require("html/prices.php")
}
else
{
print "<p>Sorry, we don't currently have any price data for this product.</p>";
}
Cheers,
David.
--
PriceTapestry.com