You are here:  » Search Results

Active Forum Topics


Search Results

Submitted by zway on Thu, 2017-11-30 01:22 in

Hey David,

How would I get the compare button to automatically click out to the cheapest merchant on the search result pages?

Thanks,

Zway

Submitted by support on Thu, 2017-11-30 09:14

Hello Zway,

Sure - add the following code to the top of html/searchresults.php

<?php
  
foreach($searchresults["products"] as $k => $product)
  {
    if (
$product["numMerchants"]>1)
    {
      
$sql "SELECT id,buy_url FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($product["name"])."' ORDER BY price";
      
database_querySelect($sql,$rows);
      
$searchresults["products"][$k]["id"] = $rows[0]["id"];
      
$searchresults["products"][$k]["buy_url"] = $rows[0]["buy_url"];
    }
    
$searchresults["products"][$k]["productHREF"] = tapestry_buyURL($searchresults["products"][$k]);
  }
?>

(note that this will affect Related Products also, but that can changed if required, just let me know...)

Cheers,
David.
--
PriceTapestry.com