Exluding Products from Search
Exluding Products from Search
How do Exclude specific products from coming up in the site search? I know it seems like an odd request, but we have duplicate products we had to create in order to do a customized quick shopping form. We don't want those showing up, as we want people to go to the form only for those products. I can't find a way to segment out a specific category or product and keep it out of the internal search.
Re: Exluding Products from Search
If you don't want to show duplicate products anywhere else in store side then on making their visibility to private/hidden will not be accessible anywhere in store side including in search also.
hope this helps!
__________________
s_ismail
AbleCommerce Customization
Free Plugins and Add-Ons
AbleCommerce Plugins and Add-Ons
Plugables Blog
__________________
s_ismail
AbleCommerce Customization
Free Plugins and Add-Ons
AbleCommerce Plugins and Add-Ons
Plugables Blog
Re: Exluding Products from Search
We do need them to shore up in our store, on the page we created for them. Just not in the search because then it takes the customer away from the page we created and into the regular product page, which will be quite confusing to them.
Re: Exluding Products from Search
Well,
I think you need to write a custom query. I have done some basic work for you check it out
Go to ConLib SearchPage.ascx.cs and locate this code
and replace with this code
For more details about custom query have a look at this
http://wiki.ablecommerce.com/index.php/Custom_Queries
I think you need to write a custom query. I have done some basic work for you check it out
Go to ConLib SearchPage.ascx.cs and locate this code
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");
}
and replace with this code
Code: Select all
protected void BindProductList()
{
Trace.Write(this.GetType().ToString(), "Begin BindProductList");
string excludeProducts="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16";//Replace with your own excluded Product Ids
ProductList.DataSource = LoadProducts(excludeProducts); //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");
}
protected List<Product> LoadProducts(string productids)
{
CommerceBuilder.Data.Database database = Token.Instance.Database;
string sql = ("SELECT ProductId FROM ac_Products WHERE ProductId NOT IN (" + productids + ")");//Comma seperated product ids
List<Product> filteredProducts = new List<Product>();
using (System.Data.Common.DbCommand selectCommand = database.GetSqlStringCommand(sql))
{
database.AddInParameter(selectCommand, "@storeId", System.Data.DbType.Int32, Token.Instance.StoreId);
using (IDataReader dr = database.ExecuteReader(selectCommand))
{
while (dr.Read())
{
int prodId = dr.GetInt32(0);
Product product= ProductDataSource.Load(prodId);
if(product!=null)
filteredProducts.Add(product);
}
}
}
return filteredProducts;
}
http://wiki.ablecommerce.com/index.php/Custom_Queries
hope this helps!
__________________
s_ismail
AbleCommerce Customization
Free Plugins and Add-Ons
AbleCommerce Plugins and Add-Ons
Plugables Blog
__________________
s_ismail
AbleCommerce Customization
Free Plugins and Add-Ons
AbleCommerce Plugins and Add-Ons
Plugables Blog
Re: Exluding Products from Search
Products with visibility hidden will not be shown in store/search by still can be accessed by their direct URLs. So if you will be linking these products manually then hidden viability may work for you.