You are here:  » Logo Merchant on Search


Logo Merchant on Search

Submitted by Tobix on Sat, 2021-04-10 06:33 in

Hi David,
In the Page searchresults.php I would like to show the logo of the best shop or even just the writing. I have not found anything working on the forum, maybe I missed some steps?

Submitted by support on Mon, 2021-04-12 10:06

Hi Tobix,

Sure - first add the following PHP section to the top of html/searchresults.php to make sure the merchant value is that of the cheapest merchant, and generate a merchantHTML value to use in the search results output:

<?php
  
foreach($searchresults["products"] as $k => $v)
  {
    if (
$v["numMerchants"] > 1)
    {
      
$sql "SELECT merchant FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($v["name"])."' ORDER BY price ASC LIMIT 1";
      
database_querySelect($sql,$rows);
      
$searchresults["products"][$k]["merchant"] = $rows[0]["merchant"];
    }
    if (
file_exists("logos/".$searchresults["products"][$k]["merchant"].$config_logoExtension))
    {
      
$searchresults["products"][$k]["merchantHTML"] = "<img src='".$config_baseHREF."logos/".str_replace(" ","%20",$searchresults["products"][$k]["merchant"]).$config_logoExtension."' />";
    }
    else
    {
      
$searchresults["products"][$k]["merchantHTML"] = $searchresults["products"][$k]["merchant"];
    }
  }
?>

Then to add the merchant name or logo to the output, insert the following inline PHP within the main loop as required:

<?php print $product["merchantHTML"]; ?>

For example to display below the link to the comparison page, look for the following code at line line 86:

          <a class='button tiny radius secondary' href='<?php print $product["productHREF"]; ?>'><?php print ($product["numMerchants"]>1?translate("Compare")." ".$product["numMerchants"]." ".translate("Prices"):translate("More Information")); ?></a>

...and REPLACE with:

          <a class='button tiny radius secondary' href='<?php print $product["productHREF"]; ?>'><?php print ($product["numMerchants"]>1?translate("Compare")." ".$product["numMerchants"]." ".translate("Prices"):translate("More Information")); ?></a>
          <br />
          <?php print $product["merchantHTML"]; ?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Tobix on Thu, 2021-04-15 17:11

works perfectly!