- Posts: 9
- Thank you received: 0
Search limited to a category
15 years 8 months ago #6262
by argyweb
Search limited to a category was created by argyweb
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
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.
15 years 8 months ago - 15 years 7 months ago #6265
by nicolas
Replied by nicolas on topic Re: Search limited to a category
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);
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: 15 years 7 months ago by nicolas.
Please Log in or Create an account to join the conversation.
15 years 7 months ago #6707
by argyweb
Replied by argyweb on topic Re: Search limited to a category
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
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.
15 years 7 months ago #6709
by nicolas
Replied by nicolas on topic Re: Search limited to a category
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.177 seconds