private SearchContent CreateSearchContent(string category, ICategory node, CatalogueUrlHelper urlHelper) {

            SearchContent sc = new SearchContent();
            sc.Title = node.Name;

            sc.Contents = node.Description;
            sc.Author = "simon";
            sc.ModuleType = this.Section.ModuleType.Name;
            sc.Path = urlHelper.GetCatalogueNodeUrl(node);
            sc.Category = category;
            sc.Site = (this.Section.Node != null ? this.Section.Node.Site.Name : String.Empty);
            sc.DateCreated = DateTime.Now;
            sc.DateModified = DateTime.Now;
            sc.SectionId = this.Section.Id;

            if (sc.Title == null || sc.Title.Length == 0) {
                sc.Title = "NODE " + node.NodeID;
            }

            if (sc.Contents == null || sc.Contents.Length == 0) {
                sc.Contents = "Desc " + (sc.Title);
            }

            sc.Summary = sc.Contents;

            return sc;
        }
        private SearchContent CreateSearchContentName(string category, IProductSummary product, CatalogueUrlHelper urlHelper) {

            SearchContent sc = new SearchContent();
            sc.Title = product.Name;

            sc.Contents = product.Name;

            sc.Author = "simon";
            sc.ModuleType = this.Section.ModuleType.Name;
            sc.Path = urlHelper.GetProductUrl(product);
            sc.Category = category;
            sc.Site = (this.Section.Node != null ? this.Section.Node.Site.Name : String.Empty);
            sc.DateCreated = DateTime.Now;
            sc.DateModified = DateTime.Now;
            sc.SectionId = this.Section.Id;

            if (sc.Title == null || sc.Title.Length == 0) {
                sc.Title = product.Name;
            }

            if (sc.Contents == null || sc.Contents.Length == 0) {
                sc.Contents = "Item " + (sc.Title);
            }

            sc.Summary = sc.Contents;

            return sc;
        }
        public SearchContent[] GetAllSearchableContent() {

            int storeID = Section.Node.Site.Id;
            string cultureCode = Section.Node.Culture;
            int maxDepth = 5;

            ArrayList searchableContent = new ArrayList();
            CatalogueUrlHelper helper = new CatalogueUrlHelper(this);
            AddRecursiveContent(0, maxDepth, CatalogueViewer.GetRootCategoryView(storeID, cultureCode), searchableContent, helper, storeID, cultureCode);
            return (SearchContent[])searchableContent.ToArray(typeof(SearchContent));
        }
        private void AddRecursiveContent(int currentLevel, int maxLevel, ICategoryView node, ArrayList searchableContent, CatalogueUrlHelper helper, int storeID, string cultureCode) {
            if (this.CurrentViewControlPath == "Modules/ECommerce/Views/Navigation.ascx") return;
     
            if (node == null || currentLevel > maxLevel) return;

            searchableContent.Add(CreateSearchContent("Node", node.CurrentNode, helper));

            

            foreach (IProductSummary product in node.ProductList) {
             
                searchableContent.Add(CreateSearchContentName(node.CurrentNode.Name, product, helper));

                foreach(ProductSynonym ps in product.SynonymList){
                 searchableContent.Add(CreateSearchContentSynonym(node.CurrentNode.Name, product, ps, helper));
                
                }
            }

            foreach (ICategory childNode in node.ChildNodes) {
                try {
                    AddRecursiveContent(currentLevel + 1, maxLevel, CatalogueViewer.GetCategoryView(storeID, cultureCode, childNode.NodeID), searchableContent, helper, storeID, cultureCode);
                   
                } catch (Exception e) {
                    log4net.LogManager.GetLogger(GetType()).Error(e);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e) {

            string msg = Request[PARAM_MESSAGE];
            if (!string.IsNullOrEmpty(msg)) {
                lblMessage.Text = msg;
                pnlMessage.Visible = true;
            }

            CatalogueViewModule controller = Module as CatalogueViewModule;
            UrlHelper = new CatalogueUrlHelper(controller);

            try {
                CatID = Int32.Parse(Request.Params[PARAM_CATEGORY_ID]);
            } catch { }
            try {
                ProductID = Int32.Parse(Request.Params[PARAM_PRODUCT_ID]);
            } catch { }

            if (CatID > 0) {
                cat = controller.CatalogueViewer.GetCategoryView(controller.Section.Node.Site.Id, controller.Section.Node.Culture, CatID);
            } else {
                cat = controller.CatalogueViewer.GetRootCategoryView(controller.Section.Node.Site.Id, controller.Section.Node.Culture);
                CatID = cat.CurrentNode.NodeID;
                IsRoot = true;
            }

            if (cat != null) {

                List<ICategory> categoryList = cat.ChildNodes;
                List<IProductSummary> productList = cat.ProductList;

                ParentID = cat.CurrentNode.ParentNodeID;

                rptCategories.DataSource = categoryList;
                rptCategories.DataBind();

                rptProducts.DataSource = productList;
                rptProducts.DataBind();

                ctlBreadCrumb.RenderBreadCrumbTrail(cat.BreadCrumbTrail);
            }
        }