Filtering serach result based on page theme

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
brianhk00
Ensign (ENS)
Ensign (ENS)
Posts: 5
Joined: Sun Dec 12, 2010 12:17 pm

Filtering serach result based on page theme

Post by brianhk00 » Mon Jan 03, 2011 12:06 am

Is it possible to filter search results based on theme?
Thanks in advance.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Filtering serach result based on page theme

Post by mazhar » Mon Jan 03, 2011 6:57 am

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.

brianhk00
Ensign (ENS)
Ensign (ENS)
Posts: 5
Joined: Sun Dec 12, 2010 12:17 pm

Re: Filtering serach result based on page theme

Post by brianhk00 » Tue Jan 04, 2011 12:40 am

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.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Filtering serach result based on page theme

Post by mazhar » Tue Jan 04, 2011 5:17 am

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.

Post Reply