You are here:  » Adding a 'visit store' button to the search results page


Adding a 'visit store' button to the search results page

Submitted by matthew on Mon, 2008-04-21 08:36 in

Hi,

I've added a column to the search results page and use the following code to add a visit store

<a rel='nofollow' class='submit_button' href='<?php print tapestry_buyURL($product); ?>' target="_blank" <?php print JavaScript_statusBar("go to ".$product["merchant"]); ?>>
Visit store</a>

But it looks as though the product id thats generated by the tapestry_buyURL is different to the id generated on the product info page.

Have you got an idea why they're not the same?

Thanks,

Matt

Submitted by support on Mon, 2008-04-21 08:43

Hello Matt,

When there is only one merchant, the id field in $product will match the merchant and your code should work - but where there are multiple merchants for a product the summary query generated by the search results page cannot specify which of the results the non-summary fields are from - so it could be one $product["merchant"] and a different $product["id"].

If this is what is causing the problem, one option is to only display the visit store link on the search results page if there is only one merchant - you could do this by wrapping your code above in the following....

<?php if ($product["numMerchants"] == 1): ?>
... visit store HTML ...
<?php endif; ?>

Cheers,
David.

Submitted by matthew on Mon, 2008-04-21 09:05

I've added the 'if' code, but it hasn't made any difference.

What I have noticed though, is that some items in the search results page don't have an id number in the jump.php link, and some do.

Matt

Submitted by support on Mon, 2008-04-21 11:06

Hi Matt,

I just added your exact code to my test server and it worked fine... Could you perhaps email me a link to the site where you have added this so that I can take a look for you? (reply to your reg code or forum registration email is the easiest way)

Cheers,
David.

Submitted by matthew on Mon, 2008-04-21 11:12

I'm at work so don't have access to my email...

http://pricebeep.co.uk/search/popularity/eee/

There's several items in that results page with no id.

Cheers

Matt

Submitted by support on Mon, 2008-04-21 11:16

Hi Matt,

It seems (at least on that page) that once there is one item without an ID then no more have the ID on that page. Could you send me your search.php and html/searchresults.php and i'll check them over for you...

Cheers,
David.

Submitted by biglion on Tue, 2016-01-12 17:47

I'm trying to implement this on the latest Price Tapestry version 15/09A but the $product["merchant"] variable comes up empty. Is there another variable name I need to use to get the Merchant name to display?

Thanks,
Erik

Submitted by support on Tue, 2016-01-12 18:51

Hello Erik,

The re-query code has been optimised since and doesn't include the merchant field by default but it can be added easily - in search.php look for the following code at line 476:

      $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,merchant,name,normalised_name,image_url,description,price,rating FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";

Bear in mind the caveat above that the visit store link should only be displayed if numMerchants is 1 since search results are generated using a summary query...

Cheers,
David.
--
PriceTapestry.com

Submitted by biglion on Tue, 2016-01-12 19:16

Exactly what I needed, Thanks!