Page 1 of 1
Filtering serach result based on page theme
Posted: Mon Jan 03, 2011 12:06 am
by brianhk00
Is it possible to filter search results based on theme?
Thanks in advance.
Re: Filtering serach result based on page theme
Posted: Mon Jan 03, 2011 6:57 am
by mazhar
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
Code: Select all
ProductCollection products = ProductDataSource.LoadForCriteria("Theme LIKE '%AbleCommerceClassic%'");
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.
Re: Filtering serach result based on page theme
Posted: Tue Jan 04, 2011 12:40 am
by brianhk00
Thanks a lot.
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");
}
I am not sure where to add your code here.
Thanks in advance.
Re: Filtering serach result based on page theme
Posted: Tue Jan 04, 2011 5:17 am
by mazhar
If you want code change then you need to replace
Code: Select all
ProductList.DataSource = ProductDataSource.NarrowSearch(_FilteredKeywords, this.CategoryId, _ManufacturerId, 0, 0, _PageSize, (_HiddenPageIndex * _PageSize), SortResults.SelectedValue);
with following
Code: Select all
ProductList.DataSource = ProductDataSource.LoadForCriteria(string.Format("Theme LIKE '%{0}%'",FilteredKeywords));
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.