You are here:  » direct link to merchant site in serch.php


direct link to merchant site in serch.php

Submitted by technoarenasol on Fri, 2013-05-24 09:17 in

Hi David

Can possible to give Direct merchant product page link in search page .....

Thank you
AMin

Submitted by support on Fri, 2013-05-24 09:40

Hi Amin,

Sure - if you look for the following code at line 346 (12/10B) of search.php

$searchresults["products"][$k]["productHREF"] = tapestry_productHREF($product);

...and REPLACE with:

if ($product["numMerchants"] == 1)
{
  $searchresults["products"][$k]["productHREF"] = tapestry_buyURL($product);
}
else
{
  $searchresults["products"][$k]["productHREF"] = tapestry_productHREF($product);
}

The above will link direct to merchant if there is only 1 merchant for the result (in which case it can be guaranteed that the buy_url is that of the cheapest (i.e. only) merchant.

If you want to link compared results directly to the cheapest merchant then a re-query would be necessary. To do this, use the following replacement instead:

if ($product["numMerchants"] > 1)
{
  $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($product["name"])."' ORDER BY price ASC LIMIT 1";
  database_querySelect($sql,$rows);
  $product = $rows[0];
}
$searchresults["products"][$k]["productHREF"] = tapestry_buyURL($product);

Cheers,
David.
--
PriceTapestry.com

Submitted by stonecold111 on Thu, 2013-08-15 20:04

There's an extra [$k] in my search.php

$searchresults["products"][$k]["productHREF"] = tapestry_productHREF($searchresults["products"][$k]);

No problem to replace the line right?

Submitted by support on Fri, 2013-08-16 08:55

Hi,

For direct to merchant links where numMerchants is 1, for distribution 13/03A in search.php first 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,buy_url,name,normalised_name,image_url,description,price,rating FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";

And then look for the following code at line 391:

$searchresults["products"][$k]["productHREF"] = tapestry_productHREF($searchresults["products"][$k]);

...and REPLACE with:

if ($product["numMerchants"]==1)
{
  $searchresults["products"][$k]["productHREF"] = tapestry_buyURL($searchresults["products"][$k]);
}
else
{
  $searchresults["products"][$k]["productHREF"] = tapestry_productHREF($searchresults["products"][$k]);
}

Cheers,
David.
--
PriceTapestry.com