here is an easy solution for the search-problem.
instead of some complicated function to get the correct page just change the sort order to move the product on top.
change the order of the second $prod_sql query (not the search query)
from:
order by pd.products_name
to:
order by field(p.products_id,'".$_GET['pID']."') desc, pd.products_name
and that's it.
there is also another error not connected to this contribution that the first pre-selected search result will point to a wrong category-path when multiple results are found.
here's another very easy fix:
find:
while ($products = tep_db_fetch_array($products_query)) {
add before
$selPath = 0;
find
$pInfo = new objectInfo($pInfo_array);
add below:
$selPath = $cPath;
find
$cPath_back = '';
add before
if ($selPath > 0) $cPath = $selPath;
now everything works correctly for me ;)