I am trying to add the product merchant logo or text name (if logo is not added) to the search results or category browsing.
I tried to add ".$product["merchant"]." within the PHP string and it didn't pull the info for a single merchant.
It would be cool to be able to have the logo or text of the product merchant if they are the sole single one with the product to show a visit site link and a more info also below for an on-site detail page to further navigate on the current site. I was testing with the current responsive version.
Wonderful Thank you. I should have remembered that sorry ;)
Works perfect. Thank you.
Because search results are generated using a summary query `merchant` isn't included in the field list - since if there are more than 1 merchant compared and the row from which non-summary fields are selected is undefined, it may not necessarily be that associated with the cheapest price. However, if there is only 1 result (numMerchants = 1 in the "product" record in the result array) then it's safe to use of course.
Firstly, to add the field to the selection, look for the following code in search.php at line 374:
$sql2 = "SELECT id,name,normalised_name,image_url,description,price,rating FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";
...and REPLACE with:
$sql2 = "SELECT id,name,normalised_name,image_url,description,price,rating,merchant FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";
With that in place, within the loop in html/searchresults.php you can use, as required for example:
<?php if ($product["numMerchants"] > 1): ?>
<p>From <?php print $product["merchant"]; ?></p>
<p><img src='<?php print $config_baseHREF; ?>logos/<?php print $product["merchant"]; ?>' ?>
<?php endif; ?>
Hope this helps!