Is it possible to filter search results based on theme?
Thanks in advance.
Filtering serach result based on page theme
Re: Filtering serach result based on page theme
Well I believe either you need to write your custom query to do this or other option could be to put theme name in product keywords section. For example simple custom query to do this could be
If you want to go with second approach where you can put theme in product's keyword field. This will make existing search options filter products for theme name query.
Code: Select all
ProductCollection products = ProductDataSource.LoadForCriteria("Theme LIKE '%AbleCommerceClassic%'");
Re: Filtering serach result based on page theme
Thanks a lot.
I believe that this is the place to add your code in "/ConLib/SearchPage.ascx.cs".
I am not sure where to add your code here.
Thanks in advance.
I believe that this is the place to add your code in "/ConLib/SearchPage.ascx.cs".
Code: Select all
protected void BindProductList()
{
Trace.Write(this.GetType().ToString(), "Begin BindProductList");
ProductList.DataSource = ProductDataSource.NarrowSearch(_FilteredKeywords, this.CategoryId, _ManufacturerId, 0, 0, _PageSize, (_HiddenPageIndex * _PageSize), SortResults.SelectedValue);
ProductList.DataBind();
NoSearchResults.Visible = (_SearchResultCount == 0);
SearchResultsAjaxPanel.Update();
Trace.Write(this.GetType().ToString(), "End BindProductList");
}
Thanks in advance.
Re: Filtering serach result based on page theme
If you want code change then you need to replace
with following
but as I mentioned earlier with this way you will loose standard search features. If you want to preserve all features plus theme search option you need to write your complete custom search function.
The other option that doesn't involves any code change is to make use of product keywords section. When you assign product a theme simply put that theme name in Keywords section as well. Store search functions can search through these keywords so if some one will try to search theme name from store it will list corresponding product.
Code: Select all
ProductList.DataSource = ProductDataSource.NarrowSearch(_FilteredKeywords, this.CategoryId, _ManufacturerId, 0, 0, _PageSize, (_HiddenPageIndex * _PageSize), SortResults.SelectedValue);
Code: Select all
ProductList.DataSource = ProductDataSource.LoadForCriteria(string.Format("Theme LIKE '%{0}%'",FilteredKeywords));
The other option that doesn't involves any code change is to make use of product keywords section. When you assign product a theme simply put that theme name in Keywords section as well. Store search functions can search through these keywords so if some one will try to search theme name from store it will list corresponding product.