You are here:  » Direct Buy URL on Search Results


Direct Buy URL on Search Results

Submitted by babyuniverse on Sun, 2013-07-28 05:17 in

Hi David,

Hope you are well!!

can you please look at a new site I am working on at {link saved}
I am only using a grid on the front index page, I have managed to ge tthe price, image and merchant to link directly to the affiliate url.

On search results {link saved} I can get the price and image to link, but cannot get the merchant name to appear. I have used the following code

<a class="merchant" href='<?php print tapestry_buyURL($product); ?>' rel='nofollow' title='<?php print $product["merchant"]; ?>'><?php print $product["merchant"]; ?></a>

Is this returned different in searchresults.php or is search.php required to be changed.

Hope this makes sense

Richard

Submitted by support on Sun, 2013-07-28 09:52

Hi Richard,

As of 13/03A each product record in $searchresults["products"] only contains the fields required for display, which doesn't include `merchant` however this can be added easily. In search.php look for the following code 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,merchant,normalised_name,image_url,description,price,rating FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";

Your code as above should then work fine.

However, note that for compared merchants, since search results are generated by a summary query you cannot be certain which merchant is in the merchant field, so you may only want to trigger the above code if numMerchants is 1, which can be done as follows:

<?php if ($product["numMerchants"]==1): ?>
<a class="merchant" href='<?php print tapestry_buyURL($product); ?>' rel='nofollow' title='<?php print $product["merchant"]; ?>'><?php print $product["merchant"]; ?></a>
<?php endif; ?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by babyuniverse on Mon, 2013-07-29 09:18

Thanks David, That works well

I am also getting the following error (not related to above code)

{code saved}

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/boutique/public_html/includes/database.php on line 32

I search on the forum and believe it is from index.php or featured.php that is causing the error, any ideas?

Index.php has the following

{code saved}

Thanks
Richard

Submitted by support on Mon, 2013-07-29 09:23

Hi Richard,

In your code from index.php; where you have:

$sqlNames[] = "'".$featured["name"]."'";

...REPLACE with:

$sqlNames[] = "'".database_safe($featured["name"])."'";

(one of the products contained an apostrophe in the name which would break the SQL with the above code)

Cheers,
David.
--
PriceTapestry.com