Hi,
It's indeed not possible to know that in the search plugin as joomla doesn't give any information about the previous page to the search plugins.
What you could do is edit the listing file of the view product (via the menu Display->Views) and add the code below to save the current category id in the session:
if(empty($this->module)){
$app =& JFactory::getApplication();
$app->setUserState('hikashop_category_id',$this->pageInfo->filter->cid);
}
Then, in the plugins/search/hikashop_products.php file, you could use the code below to retrieve the id and add it to the query :
$app =& JFactory::getApplication();
$app->setUserState('hikashop_category_id',$this->pageInfo->filter->cid);