Search limited to a category

  • Posts: 9
  • Thank you received: 0
13 years 9 months ago #6262

Hello,

I've placed the Joomla search module (product search plugin active) in a content menu (where I'm showing just one category of products)

Is is possible to limit the search just to the category where I'm in that moment.

I was hacking the code and the sql query, however i'm not able to catch the category where i am on the moment of the search.

Do you have any solution?

Example:
shop.kufuuza.com/index.php/rieragaia/product/listing
Search box (write olmo)
I just want to show the first result, it's the only one of the race where I'm looking

Thanks in advance

David

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
13 years 9 months ago #6265

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);

Last edit: 13 years 9 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 9
  • Thank you received: 0
13 years 9 months ago #6707

Hello Nicolas,

I'm trying to use the solution that you gave me, however it's not working, or I'm not able to make it work.

Adding the code in both places, the error it's the same.. Am I doing something wrong?

Fatal error: Call to a member function setUserState() on a non-object in .../templates/gk_coolfoto_black/html/com_hikashop/product/listing.php on line 16

Fatal error: Call to a member function setUserState() on a non-object in .../plugins/search/hikashop_products.php on line 117

Thanks

David

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
13 years 9 months ago #6709

Right, it's =& and not &= in the first line.

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum