0
votes

We have a custom Product Detailed View module which will retrieve product data when a query string in the URL contains a certain SKU and navigated from the product filter module page. When the Detailed Product View module loads, it will check for a query string and load the data via Ajax.

I want to integrate DNN's SearchModuleBase so that the custom modules data will show in our custom Search Results module.

I have looked at the SearchModuleBase Wiki and Introduction: http://www.dnnsoftware.com/wiki/modulesearchbase

http://www.dnnsoftware.com/community-blog/cid/154913/integrating-with-search-introducing-modulesearchbase

How can I specify the exact content I want DNN's crawler to index? For example: SKU, Page Title, Product Description?

I would also like to know how you can submit Meta Keywords from the product Object as Tags in the code-behind which can be used for search results?

All the sites I have looked at uses the old ISearchable class: http://www.adefwebserver.com/dotnetnukehelp/ISearchable/

This is the current code I have, but I think it is too basic and does not specify the Product Description, SKU and the Page Title:

   public class ProductDetailedViewModuleBase : ModuleSearchBase
        {
            public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc)
            {
                throw new NotImplementedException();
            }
        }

I have changed the manifest file to be searchable. I had to change ISearchable, IPortable and IUpgradeable to Searchable, Portable and Upgradeable.

enter image description here

I am also trying to add the SearchModuleBase but I am missing something: enter image description here

This is the front end code for generating the product info: enter image description here

2

2 Answers

2
votes

The fully-qualified class and namespace that you indicated in your manifest as your businessControllerClass is the one that implements ModuleSearchBase.

I should see something like this:

namespace MyModule.Modules.ProductDetailedView.Components
{
    public class FeatureController : ModuleSearchBase
    {
        public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc)
        {
            // TODO: convert your Product info object list to a SearchDocument object list and return
        }
    }
}

Once you have this method compiled and implemented, you can go to Settings > Schedule and run the "Site Crawler" schedule task. Attach your debugger to the DNN process and when the task executes, your GetModifiedSearchDocuments method should get hit.

For a complete tutorial with sample code on this topic, you can subscribe to dnnhero.com and check out my complete search tutorial.

2
votes

The code stub you have for GetModifiedSearchDocuments is just that. It's not fully implemented. You have to replace throw new NotImplementedException() with the code to populate the list of SearchDocument objects you will return. The SearchDocument's properties are where you assign the values for the data you want the crawler to index.

 public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc)
 {
     var searchDocs = new List<SearchDocument>();
     var productList = GetProductList();  //you write this method to return a list of your products
     foreach(var product in productList)
     {
         var searchDoc = new SearchDocument
         {
             IsActive = true,
             CultureCode = moduleInfo.CultureCode,
             ...
             Title = product.YourProductName,
             Description = product.YourProductDescription,
             Body = product.YourProductDescription,
         };
         searchDocs.Add(searchDoc);
     }
     return searchDocs;
 }

The part where you say:

I am also trying to add the SearchModuleBase, but I am missing something

I'm not sure what you're trying to accomplish, but you don't need to make any changes there to get your custom content indexing.