Hi David,
I am using the default template and want to add 3 random products on the product page under the Related products in the same fashion.
What code should I use?
Thanks
Thanks David,
For some reason, it won't work.
http://comparison.topbargains.com.au
Hi,
Easiest thing to do is if you could email me your modified products.php (reply to your reg code or forum registration email) and i'll take a look for you...
Cheers,
David.
Thanks David,
Here is the code:
{code saved}
_____________________________________________________
My Australian Shopping Comparison Site
Hi,
I have emailed you a modified version of product.php with the random products code included...
Cheers,
David.
Hi David,
any chance in getting the copy of the random product code as well?
regards
Rod
Hi,
This is quite easy to do - but you mention that you want them from the same store. Would this be the same store (merchant) as the main featured product on the page? If, so the following code is all you need to do this. Look near the end of products.php for the following line:
if (isset($related)) require("html/related.php");
To use the related.php HTML module again for your random products, add the following code on the next line:
unset($related);
unset($searchresults);
$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE merchant='".$mainProduct["merchant"]."' ORDER BY RAND() GROUP BY name LIMIT 3";
$searchresults["numRows"] = database_querySelect($sql,$rows);
$searchresults["products"] = $rows;
if ($searchresults["numRows"])
{
foreach($searchresults["products"] as $k => $related)
{
if ($config_useRewrite)
{
$searchresults["products"][$k]["productHREF"] = "product/".tapestry_hyphenate($related["name"]).".html";
if ($rewrite) $searchresults["products"][$k]["productHREF"] = "../".$searchresults["products"][$k]["productHREF"];
}
else
{
$searchresults["products"][$k]["productHREF"] = "products.php?q=".urlencode($related["name"]);
}
}
$related = true;
}
if (isset($related)) require("html/related.php");
Cheers,
David.