[Skip to main content](#vessel-content)

#   Search limited to a category

##

- **[argyweb](/forum/user/410-argyweb "View argyweb's Profile")**
- [![argyweb's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/410-argyweb "View argyweb's Profile") Topic Author
- [ Offline](/forum/user/410-argyweb)

Less More

- Posts: 9
- Thank you received: 0
-
-

15 years 9 months ago [\#6262](#6262) by [argyweb](/forum/user/410-argyweb "View argyweb's Profile")  *[Search limited to a category](/forum/4-how-to/6262-search-limited-to-a-category#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")* was created by *[argyweb](/forum/user/410-argyweb "View argyweb's Profile")*

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](http://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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzYyNjItc2VhcmNoLWxpbWl0ZWQtdG8tYS1jYXRlZ29yeT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

15 years 9 months ago -  15 years 9 months ago [\#6265](#6265) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Search limited to a category](/forum/4-how-to/6262-search-limited-to-a-category#6265 "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")*

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-&gt;Views) and add the code below to save the current category id in the session:

if(empty($this-&gt;module)){
$app =&amp; JFactory::getApplication();
$app-&gt;setUserState('hikashop_category_id',$this-&gt;pageInfo-&gt;filter-&gt;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 =&amp; JFactory::getApplication();
$app-&gt;setUserState('hikashop_category_id',$this-&gt;pageInfo-&gt;filter-&gt;cid);

Last edit: 15 years 9 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzYyNjItc2VhcmNoLWxpbWl0ZWQtdG8tYS1jYXRlZ29yeT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[argyweb](/forum/user/410-argyweb "View argyweb's Profile")**
- [![argyweb's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/410-argyweb "View argyweb's Profile") Topic Author
- [ Offline](/forum/user/410-argyweb)

Less More

- Posts: 9
- Thank you received: 0
-
-

15 years 9 months ago [\#6707](#6707) by [argyweb](/forum/user/410-argyweb "View argyweb's Profile")  Replied by *[argyweb](/forum/user/410-argyweb "View argyweb's Profile")* on topic *[Re: Search limited to a category](/forum/4-how-to/6262-search-limited-to-a-category#6707 "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")*

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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzYyNjItc2VhcmNoLWxpbWl0ZWQtdG8tYS1jYXRlZ29yeT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

15 years 9 months ago [\#6709](#6709) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Search limited to a category](/forum/4-how-to/6262-search-limited-to-a-category#6709 "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")*

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzYyNjItc2VhcmNoLWxpbWl0ZWQtdG8tYS1jYXRlZ29yeT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.054 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
