I am trying to Implement the ISearchable on one of our modules.
Visual Studio is indicating that SearchItemInfo is Obsolete and Deprecated in DNN 7.1.
I found this article, but it does show the new alternative code which I must use and there is so many internal functions on GitHub.
https://www.dnnsoftware.com/answers/searchdatastorecontroller-is-obsolete-in-71
public SearchItemInfoCollection
GetSearchItems(DotNetNuke.Entities.Modules.ModuleInfo ModInfo)
{
SearchItemInfoCollection SearchItemCollection = new SearchItemInfoCollection();
List<TestModuleInfo> colTestModules = GetTestModules(ModInfo.ModuleID);
foreach (TestModuleInfo objTestModule in colTestModules)
{
SearchItemInfo SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, objTestModule.Content, objTestModule.CreatedByUser, objTestModule.CreatedDate, ModInfo.ModuleID, objTestModule.ItemId.ToString(), objTestModule.Content, "ItemId=" + objTestModule.ItemId.ToString());
SearchItemCollection.Add(SearchItem);
}
return SearchItemCollection;
throw new System.NotImplementedException("The method or operation is not implemented.");
}
I did try to write the following method and attached a breakpoint on GetModifiedSearchDocuments and Scheduled the Site Crawler to crawl the site, but it is never hit. Also, by implementing this code, will this show the checkbox on the module which will enable you to turn ISearchable on and off?
//uncomment the interfaces to add the support.
public class FeatureController : ModuleSearchBase
{
public CommonDataDefinitions.Products.WebProductDetails ProductDetails { get; set; } = null;
public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc)
{
var searchDocs = new List<SearchDocument>();
var products = new List<QuickProduct>
{
new QuickProduct("CT4455", "Soundbar", "The soundbar is used for entertainment purposes." ),
new QuickProduct("BD5333", "Laser Pointer", "For Presentations." )
};
foreach (var product in products)
{
var searchDoc = new SearchDocument
{
IsActive = true,
CultureCode = moduleInfo.CultureCode,
Title = product.Title,
Description = product.Description,
Body = product.Description,
};
searchDocs.Add(searchDoc);
}
return searchDocs;
}
}
public class QuickProduct
{
public string SKU { get; set; }
public string Title{ get; set; }
public string Description { get; set; }
public QuickProduct(string SKU, string Title, string Description)
{
this.SKU = SKU;
this.Title = Title;
this.Description = Description;
}
}