Limiting Search Results
Limiting Search Results
Is there a way to limit search results to a specific category? I would assume that this would be controlled through the ConLib/SearchPage.ascx.cs file, but do not know how this would be written in.
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot
Brewhaus (America) Inc.
Hot Sauce Depot
Re: Limiting Search Results
Check out the Products.ProductDataSource class in the API docs. Both AdvanchedSearch() and NarrowSearch() methods accept a CategoryId argument.
Nick Cole
http://www.ethofy.com
http://www.ethofy.com
Re: Limiting Search Results
What we need to do is limit the entire search to a single (head) category. Any item that belongs to a different category should not be returned. I assume that there must be an arguement in the SearchPage.ascx.cs file that will allow for this, but I cannot seem to nail it down.
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot
Brewhaus (America) Inc.
Hot Sauce Depot
Re: Limiting Search Results
Code: Select all
public int CategoryId
{
get
{
if (ViewState["CategoryId"] == null)
ViewState["CategoryId"] = PageHelper.GetCategoryId();
return (int)ViewState["CategoryId"];
}
Nick Cole
http://www.ethofy.com
http://www.ethofy.com
Re: Limiting Search Results
That worked perfectly- thank you! The only issue was that moving to page 2 of the results expanded to include all categories in the 'Narrow Search' section, so we just bumped the number of results per page to 36 in order to avoid this issue for most cases.
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot
Brewhaus (America) Inc.
Hot Sauce Depot
Re: Limiting Search Results
Although items from categories not selected by using the code above do not show on the original search, they do show up when clicking on the 'expand' options, it does include other categories. Is there another spot in the file where we need to make the same stipulation on the category to ensure that other categories do not show up?
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot
Brewhaus (America) Inc.
Hot Sauce Depot
Re: Limiting Search Results
Check the admin search module, It defines a Search method that take a Boolean parameter to specify you want to search subcategories or not.
Re: Limiting Search Results
Actually, when expanding the search it opens up to categories at the same level. Because we will be operating two stores on the db, we have placed all of the 'store 1' categories and products into one category, and the 'store 2' categories and products into a different category. This keeps things neat and tidy in the catalog. Because one store carries all items from both stores, there is no need to limit the search for that store. But the other store carries only the products in 'store 1'. By limiting the search as discussed earlier in this thread, a basic search returns only the items inside of the 'store 1' category / sub-categories. But, if a customer clicks on the 'expand' option on the search results page, the 'store 2' main category shows up if the search term matches any products in that category.
I do not know if there is any way to limit what category will be returned in the search results, regardless of whether a person tries to narrow or expand the results, but that is what we are hoping to do.
I do not know if there is any way to limit what category will be returned in the search results, regardless of whether a person tries to narrow or expand the results, but that is what we are hoping to do.
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot
Brewhaus (America) Inc.
Hot Sauce Depot
Re: Limiting Search Results
You may try to customize the CateogrySearchSidebar control to take care of your requirements.