You are here:  » Merchants on search results

Support Forum



Merchants on search results

Submitted by esogut on Mon, 2010-02-22 22:23 in

Hi David,

IT would very nice if it's possible to print out all the merchants for a product on the search results so that the customer doesnt have to drilldown to the product page.
Do you have a solution for this...

Thnx

Submitted by support on Tue, 2010-02-23 10:06

Hi,

The search results are actually generated by a summary style SQL query; so as it stands the information for each merchant isn't in the result set. It can be easily brought in if that is what you would like to do; but it involves another query for every search results (so if 10 per page; 10 additional queries).

Other users have done similar; and it shouldn't be a problem on niche sites; but I would advise against this for very large sites.

The modification can be added to html/searchresults.php; for example as follows; in this case replacing the price column with a table showing each merchant, their price, and a Visit Store link:

<div class='searchresults'>
  <table width='100%'>
    <?php foreach($searchresults["products"] as $product): ?>
      <tr>
        <td>
          <?php if ($product["image_url"]): ?>
          <a href='<?php print $product["productHREF"]; ?>'><img border='0' width='80' src='<?php print $product["image_url"]; ?>' alt='<?php print $product["name"]; ?>' /></a>
          <?php endif; ?>
        </td>
        <td width='50'>&nbsp;</td>
        <td valign='middle'>
          <?php if ($config_useInteraction): ?>
          <h4><a href='<?php print $product["productHREF"]; ?>'><?php print $product["name"]; ?></a> <?php if ($product["rating"]) print tapestry_stars($product["rating"],""); ?></h4>
          <?php else: ?>
          <h4><a href='<?php print $product["productHREF"]; ?>'><?php print $product["name"]; ?></a></h4>
          <?php endif; ?>
          <p><?php print substr($product["description"],0,250); ?></p>
        </td>
        <td width='50'>&nbsp;</td>
        <td>
        <?php
        print "<table border='0'>";
        $sql = "SELECT * FROM `".$config_databaseTablePrefix."products`
                  WHERE name='".database_safe($product["name"])."'
                  ORDER BY price";
        database_querySelect($sql,$rows);
        foreach($rows as $row)
        {
          print "<tr>";
          print "<td>".$row["merchant"]."</td>";
          print "<td align='right'>".$config_currencyHTML.$row["price"]."</td>";
          print "<td><nobr><a href='".tapestry_buyURL($row)."'>Visit Store</a></nobr></td>";
          print "</tr>";
        }
        print "</table>";
        ?>
        </td>
      </tr>
    <?php endforeach; ?>
  </table>
</div>

Cheers,
David.

Submitted by shoppersbase on Tue, 2011-11-29 17:13

Hi David

I was looking for something like what was discussed above but mine is slightly different in the sense that I just want to show the merchants in an additional column, so take this page {link saved}

i just wanted an additional column to include the merchant name but it must be hyperlinked with the BUY URL and opens in a new window.

Thanks

joseph

Submitted by support on Wed, 2011-11-30 11:10

Hi Joseph,

Sure, bear in mind the merchant name and link can only be displayed if there is only one merchant ($product["numMerchants"]) otherwise it is not defined which merchant name will be in $product["merchant"]. To do this, look for the following code beginning at line 32 of html/searchresults.php

      </tr>
    <?php endforeach; ?>

...and REPLACE with:

        <td width='50'>&nbsp;</td>
        <td valign='middle' align='center'>
        <?php if($product["numMerchants"] == 1): ?>
        <a href='<?php print tapestry_buyURL($product); ?>'>Buy now from<br /><?php print $product["merchant"];</a>
        <?php endif; ?>
        </td>
      </tr>
    <?php endforeach; ?>

Cheers,
David.
--
PriceTapestry.com