Hello David,
hope you are fine and welcome again after holidays
In my installation I prefer to remove/not use the single product page, so in search results I'd like to change from
<?php print $product["productHREF"]; ?>
to
<?php print tapestry_buyURL($priceProduct); ?>
Is it possible, right? And which modifications to do for this?
Thanks!
Thanks David,
but I still see the link to the product instead the link to the buy url, I mean I see
$searchresults["products"][$k]["productHREF"] = "product/".tapestry_hyphenate($product["name"]).".html";
but, if possible, I prefer see the buyurl of each merchant.
Hi,
The above code will only link to the merchant if there is only 1 merchant - is that the case with the searches you have tried and it is still going to the product page?
Cheers,
David.
Hi,
no I mean search results where there are many merchants. This is an example page:
{link saved}
Thanks
Hi,
That should be how it's working - could you email me your search.php and html/searchresults.php and I'll check it out for you...
Cheers,
David.
Hi,
Can you please advise how to amend this slightly so it opens the buy url in a new window - target=_blank
Thanks
Richard
Hi Richard,
This is best done within the includes/tapestry.php file. In that file, you will find the following code beginning at line 51:
if ($config_useTracking)
{
return $config_baseHREF."jump.php?id=".$product["id"];
}
else
{
return $product["buy_url"];
}
REPLACE that with:
if ($config_useTracking)
{
$retval = $config_baseHREF."jump.php?id=".$product["id"];
}
else
{
$retval = $product["buy_url"];
}
return $retval."' target='_BLANK";
It may look like there is a ' missing after _BLANK, but that's OK - it' balanced out by the additional ' added after the Buy URL ($retval in the above code), so the HTML that is ultimately generated will be valid!
Cheers,
David.
Hello David,
i try to change my search.php when have only 1 product link directly to the product buy link.
foreach($searchresults["products"] as $k => $product)
{
$searchresults["products"][$k] = array_merge($searchresults["products"][$k],$rows3[$product["id"]]);
// saiu https://www.pricetapestry.com/node/3467
//$searchresults["products"][$k]["productHREF"] = tapestry_productHREF($searchresults["products"][$k]);
//if ($product["numMerchants"] == 1)
//{
// $searchresults["products"][$k]["productHREF"] = tapestry_buyURL($product);
//}
//else
// $searchresults["products"][$k]["productHREF"] = tapestry_productHREF($searchresults["products"][$k]);
//}
But not work!
Thanks,
Marco Saiu
Hello Marco,
The modification looks OK but prior to 16/09A the buy_url field is not present in $product so if you are not using tracking ($config_useTracking = FALSE) the tapestry_buyURL() function would return an empty link. To add the field, 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,name,normalised_name,image_url,description,price,rating,buy_url FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";
Cheers,
David.
--
PriceTapestry.com
Hi,
This is a straight forward modification to search.php. I'll post the modifications for both distributions of Price Tapestry as I know you've been a user for a long time...
Latest Distribution (11/09A)
Look for the following code beginning at line 270:
if ($config_useRewrite)
{
$searchresults["products"][$k]["productHREF"] = $config_baseHREF."product/".tapestry_hyphenate($product["normalised_name"]).".html";
}
else
{
$searchresults["products"][$k]["productHREF"] = $config_baseHREF."products.php?q=".urlencode($product["normalised_name"]);
}
...and REPLACE with:
if ($product["numMerchants"] == 1)
{
$searchresults["products"][$k]["productHREF"] = tapestry_buyURL($product);
}
elseif ($config_useRewrite)
{
$searchresults["products"][$k]["productHREF"] = $config_baseHREF."product/".tapestry_hyphenate($product["normalised_name"]).".html";
}
else
{
$searchresults["products"][$k]["productHREF"] = $config_baseHREF."products.php?q=".urlencode($product["normalised_name"]);
}
Original Distribution (01/06A)
Look for the following code beginning at line 164:
if ($config_useRewrite)
{
$searchresults["products"][$k]["productHREF"] = "product/".tapestry_hyphenate($product["name"]).".html";
if ($rewrite) $searchresults["products"][$k]["productHREF"] = "../../".$searchresults["products"][$k]["productHREF"];
}
else
{
$searchresults["products"][$k]["productHREF"] = "products.php?q=".urlencode($product["name"]);
}
...and REPLACE with:
if ($product["numMerchants"] == 1)
{
$searchresults["products"][$k]["productHREF"] = tapestry_buyURL($product);
}
elseif ($config_useRewrite)
{
$searchresults["products"][$k]["productHREF"] = "product/".tapestry_hyphenate($product["name"]).".html";
if ($rewrite) $searchresults["products"][$k]["productHREF"] = "../../".$searchresults["products"][$k]["productHREF"];
}
else
{
$searchresults["products"][$k]["productHREF"] = "products.php?q=".urlencode($product["name"]);
}
Cheers,
David.