Okay guys, I am at a stump here.
Basically the problem I have is that when people are searching for something they are mistyping the code as a lot of the time they involved multiple 0's, for example when searching for: K00000WEFLZ
they are mistyping the 0's and then the product result is returning with nothing, I am basically looking to try and make it so that the search checks if the search contains a certain amount of 0's after the letter "K" (as K will always have say 10+ ID numbers and at least 4-5 0's) and if it does it replaces it with "*" during the searching operation and still allows you to find the product no matter how wrong they type the problem.
I am aware I will have to make a custom class and override the default for this (however a lot of this can not be accessed/is private) as the default search pattern can not be changed as this will change it for everyone and I only want it for this specific site.
I also can not use a wildcard at the start or the ending of this as it would match miles to many results as it has a huge catalog.
As far as I know this is the code that handles the search with the class for the default logic:
protected virtual IList<Product> CreateCustomCollection()
{
var list = new List<Product>();
switch (mode)
{
case ProductRepeaterMode.Search:
if (Page.Request.QueryString["search"] != null && Page.Request.QueryString["search"].Length != 0)
{
bool[] customString = new bool[5] { SearchCustomString1, SearchCustomString2, SearchCustomString3, SearchCustomString4, SearchCustomString5 };
IList<Product> results = Fabric.ObjectProvider.Get<IProductSearchCommand>().Search(Page.Request.QueryString["search"], out searchWords, IncludeSkus, IsPublicFacing, customString, CoreHttpModule.Session);
var retailOrder = WebStoreManager.CurrentOrder as IRetailOrder;
var accountOrder = WebStoreManager.CurrentOrder as IAccountOrder;
IList<Product> productsToRemove = new List<Product>();
IList<Product> productsToAdd = new List<Product>();
foreach (var product in results)
{
if (hideRestrictedProducts)
{
if (retailOrder != null)
{
if (!product.CanBePurchasedByRetailCustomer || product.AgentOnly)
productsToRemove.Add(product);
}
else
{
if (accountOrder != null)
{
var add = false;
if (product.CanBePurchasedOnAccount)
add = true;
if (product.AgentOnly)
{
if (accountOrder.Agent != null)
add = true;
else
add = false;
}
if (!add)
productsToRemove.Add(product);
}
}
}
// Replace SKUs with lines
if (resolveSkusToLines)
{
var sku = product.Role as SkuProductRole;
if (sku != null)
{
productsToRemove.Add(product);
if (sku.Owner != null && sku.Owner.Product != null)
{
var line = sku.Owner.Product;
if (!results.Contains(line) && !productsToAdd.Contains(line))
productsToAdd.Add(line);
}
}
}
}
foreach (Product product in productsToAdd)
{
results.Add(product);
}
foreach (Product product in productsToRemove)
{
results.Remove(product);
}
foreach (var result in results)
list.Add(result);
}
break;
}
return list;
}