You are here:  » Noresults.php random products


Noresults.php random products

Submitted by zway on Tue, 2018-01-16 00:35 in

Hi David,

Any idea how to show 10 random products on the noresults page?

Thanks!

Submitted by support on Tue, 2018-01-16 09:38

Hi,

Here's the code to add to html/noresults.php for 10 random products...

<?php
  $sql 
"SELECT *,COUNT(id) AS numMerchants,MIN(price) as minPrice FROM `".$config_databaseTablePrefix."products` GROUP BY search_name ORDER BY RAND() LIMIT 10";
  if (
database_querySelect($sql,$rows))
  {
    
$searchresults["products"] = $rows;
    foreach(
$searchresults["products"] as $k => $product)
    {
      
$searchresults["products"][$k]["productHREF"] = tapestry_productHREF($searchresults["products"][$k]);
    }
    require(
"html/searchresults.php");
  }
?>

Cheers,
David.
--
PriceTapestry.com