DotNetNuke® is the ideal platform for building professional websites and web applications with dynamic content and interactive features. DotNetNuke store module is an ecommerce module which is running on DNN platform. This module contains lots of features. But I saw there was not a product search module. The module team leader Gilles Le Pigocher and Benoit Sarton helped me to develop this feature. Gilles Le Pigocher has added this to his long to do list. So this will be available in the future with a future store version. But until then this will be useful to all of you. Still you can use the store module with the search module what I have given. As you know this module contains 21 projects. Then I have added only source file codes with my modified codes. If you have any questions I am ready to help you. Once again my special thanks to my two French friends Gilles Le Pigocherand Benoît Sarton for their effort and all the advices.


Catalog.ascx.cs

using System;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
using DotNetNuke.Security;
using DotNetNuke.Modules.Store.Admin;
using DotNetNuke.Modules.Store.Catalog;
using DotNetNuke.Modules.Store.Components;
using System.Web;

namespace DotNetNuke.Modules.Store.WebControls
{
 public enum ProductListTypes
 {
        New,
  Featured,
  Popular,
  Category,

        MySearchResult
 }

 /// 
 /// Summary description for Media.
 /// 
 public partial class Catalog : PortalModuleBase, IActionable
 {
  #region Private Members

        private ModuleSettings moduleSettings;
        private StoreInfo storeInfo;
        private string templatesPath = "";
  private CatalogNavigation catalogNav;
  private CategoryInfo categoryInfo = new CategoryInfo();
  private ProductInfo productInfo = new ProductInfo();
        private string npTitle = null;
        private string fpTitle = null;

        private string MSTitle = null;

        private string ppTitle = null;
        private string cpTitle = null;
        private enum MetaTags
        {
            Title = 1,
            Keywords,
            Description,
        }
        private Regex regTokens = new Regex("\\[\\w+\\]", RegexOptions.IgnoreCase | RegexOptions.Compiled);

        #endregion

  #region Public Properties

  public ModuleSettings ModuleSettings
  {
   get{return moduleSettings;}
  }

  public Int32 CategoryID
  {
   get {return catalogNav.CategoryID;}
  }

  public Int32 ProductID
  {
   get {return catalogNav.ProductID;}
  }

        public DotNetNuke.Framework.CDefault BasePage
        {
            get { return (DotNetNuke.Framework.CDefault)this.Page; }
        }

        #endregion

  #region Web Form Designer generated code

  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: This call is required by the ASP.NET Web Form Designer.
   //
   InitializeComponent();
   base.OnInit(e);

        }
  
  /// 
  ///  Required method for Designer support - do not modify
  ///  the contents of this method with the code editor.
  /// 
  private void InitializeComponent()
  {
            if (storeInfo == null)
            {
                StoreController storeController = new StoreController();
                storeInfo = storeController.GetStoreInfo(PortalId);
            }
        }

  #endregion

  #region Events

  protected void Page_Load(object sender, System.EventArgs e)
  {
            if (storeInfo != null)
            {
                npTitle = Localization.GetString("NPTitle.Text", this.LocalResourceFile);
                fpTitle = Localization.GetString("FPTitle.Text", this.LocalResourceFile);

                MSTitle = Localization.GetString("MSTitle.Text", this.LocalResourceFile);

                ppTitle = Localization.GetString("PPTitle.Text", this.LocalResourceFile);
                cpTitle = Localization.GetString("CPTitle.Text", this.LocalResourceFile);

                try
                {
                    if (storeInfo.PortalTemplates)
                    {
                        templatesPath = PortalSettings.HomeDirectoryMapPath + "Store\\";
                        CssTools.AddCss(this.Page, PortalSettings.HomeDirectory + "Store", PortalId);
                    }
                    else
                    {
                        templatesPath = MapPath(ModulePath) + "\\";
                        CssTools.AddCss(this.Page, this.TemplateSourceDirectory, PortalId);
                    }

                    moduleSettings = new ModuleSettings(this.ModuleId, this.TabId);

                    catalogNav = new CatalogNavigation(Request.QueryString);

                    if (catalogNav.CategoryID == Null.NullInteger)
                    {
                        if (bool.Parse(moduleSettings.General.UseDefaultCategory))
                        {
                            catalogNav.CategoryID = int.Parse(moduleSettings.General.DefaultCategoryID);
                            Response.Redirect(catalogNav.GetNavigationUrl(), true);
                        }
                    }

                    if (catalogNav.ProductID != Null.NullInteger)
                    {
                        ProductController productController = new ProductController();
                        productInfo = productController.GetProduct(PortalId, catalogNav.ProductID);
                        catalogNav.CategoryID = productInfo.CategoryID;
                    }

                    if (catalogNav.CategoryID != Null.NullInteger)
                    {
                        CategoryController categoryController = new CategoryController();
                        categoryInfo = categoryController.GetCategory(catalogNav.CategoryID);
                    }

                    if (storeInfo.SEOFeature)
                    {
                        BasePage.Title = SEO(Localization.GetString("ListSEOTitle", this.LocalResourceFile), MetaTags.Title);
                        BasePage.Description = SEO(Localization.GetString("ListSEODescription", this.LocalResourceFile), MetaTags.Description);
                        BasePage.KeyWords = SEO(Localization.GetString("ListSEOKeywords", this.LocalResourceFile), MetaTags.Keywords);
                    }

                    this.Controls.Add(TemplateController.ParseTemplate(templatesPath, moduleSettings.General.Template, new ProcessTokenDelegate(processToken)));
                }
                catch (Exception ex)
                {
                    Exceptions.ProcessModuleLoadException(this, ex);
                }
            }
            else
            {
                string ErrorSettings = Localization.GetString("ErrorSettings", this.LocalResourceFile);
                string ErrorSettingsHeading = Localization.GetString("ErrorSettingsHeading", this.LocalResourceFile);
                DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, ErrorSettingsHeading, ErrorSettings, DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.YellowWarning);
            }
        }

  #endregion

  #region Private Functions

  private Control processToken(string tokenName)
  {
   ProductController productController = new ProductController();
   ArrayList productList = new ArrayList();

   switch (tokenName.ToUpper())
   {
    case "MESSAGE":
                    if (bool.Parse(moduleSettings.General.ShowMessage) && categoryInfo != null)
                    {
                        Panel pnlMessage = new Panel();
                        pnlMessage.CssClass = "StoreMessage";
                        if (categoryInfo != null)
                        {
                            string message = Server.HtmlDecode(categoryInfo.Message);
                            if (message != Null.NullString)
                            {
                                Panel pnlCategoryMessage = new Panel();
                                pnlCategoryMessage.CssClass = "StoreCategoryMessage";
                                Literal litCategoryMessage = new Literal();
                                litCategoryMessage.Text = System.Web.HttpUtility.HtmlDecode(message);
                                pnlCategoryMessage.Controls.Add(litCategoryMessage);
                                pnlMessage.Controls.Add(pnlCategoryMessage);
                            }
                        }

                        if (catalogNav.CategoryID != Null.NullInteger)
                        {
                            //sub categories...
                            CategoryController controller = new CategoryController();
                            ArrayList subCategories = controller.GetCategories(PortalId, false, catalogNav.CategoryID);
                            if (subCategories.Count > 0)
                            {
                                HtmlGenericControl pSubCategories = new HtmlGenericControl("p");
                                pSubCategories.Attributes.Add("class", "StoreSubCategories");

                                LiteralControl BreakRow = new LiteralControl(Localization.GetString("BeforeSubCategories", this.LocalResourceFile));
                                pSubCategories.Controls.Add(BreakRow);

                                Boolean bIsFirst = true;
                                foreach (CategoryInfo category in subCategories)
                                {
                                    if (bIsFirst)
                                    {
                                        bIsFirst = false;
                                    }
                                    else
                                    {
                                        LiteralControl BreakRow2 = new LiteralControl(Localization.GetString("BetweenSubCategories", this.LocalResourceFile));
                                        pSubCategories.Controls.Add(BreakRow2);
                                    }
                                    HyperLink link = new HyperLink();
                                    link.Text = category.CategoryName;
                                    link.CssClass = "StoreSubCategoryItem";
                                    StringDictionary replaceParams = new StringDictionary();
                                    replaceParams["CategoryID"] = category.CategoryID.ToString();
                                    replaceParams["ProductID"] = Null.NullString;
                                    replaceParams["PageIndex"] = Null.NullString;
                                    link.NavigateUrl = catalogNav.GetNavigationUrl(replaceParams, storeInfo.StorePageID);
                                    pSubCategories.Controls.Add(link);
                                }
                                BreakRow = new LiteralControl(Localization.GetString("AfterSubCategories", this.LocalResourceFile));
                                pSubCategories.Controls.Add(BreakRow);
                                pnlMessage.Controls.Add(pSubCategories);
                            }
                        }
                        return pnlMessage;
                    }
                    else
                        return null;

                case "NEW":
                    if (bool.Parse(moduleSettings.General.ShowNewProducts))
                    {
                        if (catalogNav.CategoryID != Null.NullInteger)
                        {
                            GetNewProducts(catalogNav.CategoryID, productList);
                            productList = TruncateList(productList, int.Parse(moduleSettings.NewProducts.RowCount) * int.Parse(moduleSettings.NewProducts.ColumnCount));
                            return LoadProductList(productList, ProductListTypes.New);
                        }
                        else
                        {
                            GetPortalNewProducts(PortalId, productList);
                            productList = TruncateList(productList, int.Parse(moduleSettings.NewProducts.RowCount) * int.Parse(moduleSettings.NewProducts.ColumnCount));
                            return LoadProductList(productList, ProductListTypes.New);
                        }
                    }
                    else
                    {
                        return null;
                    }

    case "FEATURED":
     if (bool.Parse(moduleSettings.General.ShowFeaturedProducts))
     {
      if(catalogNav.CategoryID != Null.NullInteger)
      {
                            GetFeaturedProducts(catalogNav.CategoryID, productList);
       productList = TruncateList(productList, int.Parse(moduleSettings.FeaturedProducts.RowCount) * int.Parse(moduleSettings.FeaturedProducts.ColumnCount));
       return LoadProductList(productList, ProductListTypes.Featured);
      }
      else
      {
                            GetPortalFeaturedProducts(PortalId, productList);
       productList = TruncateList(productList, int.Parse(moduleSettings.FeaturedProducts.RowCount) * int.Parse(moduleSettings.FeaturedProducts.ColumnCount));
       return LoadProductList(productList, ProductListTypes.Featured);
      }
     }
     else
     {
      return null;
     }


                case "MYSEARCHRESULT":

                    if (bool.Parse(moduleSettings.General.ShowMYSEARCHProducts))
                    {

                        if (catalogNav.CategoryID != Null.NullInteger)
                        {
                            GetMYSEARCHProducts(catalogNav.CategoryID, productList, catalogNav.SearchText, catalogNav.SearchField);
                            productList = TruncateList(productList, int.Parse(moduleSettings.MYSEARCHProducts.RowCount) * int.Parse(moduleSettings.MYSEARCHProducts.ColumnCount));
                            return LoadProductList(productList, ProductListTypes.MySearchResult);
                        }
                        else
                        {
                            GetPortalMYSEARCHProducts(PortalId, productList, catalogNav.SearchText, catalogNav.SearchField);
                            productList = TruncateList(productList, int.Parse(moduleSettings.MYSEARCHProducts.RowCount) * int.Parse(moduleSettings.MYSEARCHProducts.ColumnCount));
                            return LoadProductList(productList, ProductListTypes.MySearchResult);
                        }
                    }
                    else
                    {
                        return null;
                    }



    case "POPULAR":
     if (bool.Parse(moduleSettings.General.ShowPopularProducts))
     {
      if(catalogNav.CategoryID != Null.NullInteger)
      {
                            GetPopularProducts(catalogNav.CategoryID, productList);
       productList = TruncateList(productList, int.Parse(moduleSettings.PopularProducts.RowCount) * int.Parse(moduleSettings.PopularProducts.ColumnCount));
       return LoadProductList(productList, ProductListTypes.Popular);
      }
      else
      {
                            GetPortalPopularProducts(PortalId, productList);
                            productList = TruncateList(productList, int.Parse(moduleSettings.PopularProducts.RowCount) * int.Parse(moduleSettings.PopularProducts.ColumnCount));
       return LoadProductList(productList, ProductListTypes.Popular);
      }
     }
     else
     {
      return null;
     }

    case "CATEGORY":
     if (bool.Parse(moduleSettings.General.ShowCategoryProducts))
     {
      if(catalogNav.CategoryID != Null.NullInteger && catalogNav.ProductID == Null.NullInteger)
      {
                            GetCategoryProducts(catalogNav.CategoryID, productList);
       return LoadProductList(productList, ProductListTypes.Category);
      }
      else
      {
       return null;
      }
     }
     else
     {
      return null;
     }

    case "DETAIL":
     if(bool.Parse(moduleSettings.General.ShowProductDetail) && catalogNav.ProductID != Null.NullInteger)
     {
      return LoadProductDetail();
     }
     else
     {
      return null;
     }

    default:
     LiteralControl litText = new LiteralControl(tokenName);
     return litText;
   }
  }

        private void GetNewProducts(int categoryID, ArrayList products)
        {
            CategoryController categoryController = new CategoryController();
            ProductController productController = new ProductController();

            CategoryInfo category = categoryController.GetCategory(categoryID);

            foreach (ProductInfo product in productController.GetNewProducts(categoryID, false))
            {
                if (storeInfo.ProductsBehavior == (int)Behavior.HideProduct && product.StockQuantity < 1)
                {
                    // Do nothing, in this case the product is hidden
                }
                else
                    products.Add(product);
            }

            foreach (CategoryInfo childCategory in categoryController.GetCategories(PortalId, false, categoryID))
            {
                if (childCategory.CategoryID != Null.NullInteger)
                {
                    GetNewProducts(childCategory.CategoryID, products);
                }
            }
        }

        private void GetPortalNewProducts(int portalID, ArrayList products)
        {
            ProductController productController = new ProductController();

            foreach (ProductInfo product in productController.GetPortalNewProducts(portalID, false))
            {
                if (storeInfo.ProductsBehavior == (int)Behavior.HideProduct && product.StockQuantity < 1)
                {
                    // Do nothing, in this case the product is hidden
                }
                else
                    products.Add(product);
            }
        }

        private void GetFeaturedProducts(int categoryID, ArrayList products)
        {
            CategoryController categoryController = new CategoryController();
            ProductController productController = new ProductController();

            CategoryInfo category = categoryController.GetCategory(categoryID);

            foreach (ProductInfo product in productController.GetFeaturedProducts(categoryID, false))
            {
                if (storeInfo.ProductsBehavior == (int)Behavior.HideProduct && product.StockQuantity < 1)
                {
                    // Do nothing, in this case the product is hidden
                }
                else
                    products.Add(product);
            }

            foreach (CategoryInfo childCategory in categoryController.GetCategories(PortalId, false, categoryID))
            {
                if (childCategory.CategoryID != Null.NullInteger)
                {
                    GetFeaturedProducts(childCategory.CategoryID, products);
                }
            }
        }

        private void GetPortalFeaturedProducts(int portalID, ArrayList products)
        {
            ProductController productController = new ProductController();

            foreach (ProductInfo product in productController.GetPortalFeaturedProducts(portalID, false))
            {
                if (storeInfo.ProductsBehavior == (int)Behavior.HideProduct && product.StockQuantity < 1)
                {
                    // Do nothing, in this case the product is hidden
                }
                else
                    products.Add(product);
            }
        }


        private void GetMYSEARCHProducts(int categoryID, ArrayList products, string SearchText, string SearchField)
        {
            CategoryController categoryController = new CategoryController();
            ProductController productController = new ProductController();

            CategoryInfo category = categoryController.GetCategory(categoryID);

            foreach (ProductInfo product in productController.GetMYSEARCHProducts(categoryID, false,SearchText,SearchField))
            {
                if (storeInfo.ProductsBehavior == (int)Behavior.HideProduct && product.StockQuantity < 1)
                {
                    // Do nothing, in this case the product is hidden
                }
                else
                    products.Add(product);
            }

            foreach (CategoryInfo childCategory in categoryController.GetCategories(PortalId, false, categoryID))
            {
                if (childCategory.CategoryID != Null.NullInteger)
                {
                    GetMYSEARCHProducts(childCategory.CategoryID, products,SearchText,SearchField);
                }
            }
        }

        private void GetPortalMYSEARCHProducts(int portalID, ArrayList products, string SearchText, string SearchField)
        {
            ProductController productController = new ProductController();

            foreach (ProductInfo product in productController.GetPortalMYSEARCHProducts(portalID, false,SearchText,SearchField))
            {
                if (storeInfo.ProductsBehavior == (int)Behavior.HideProduct && product.StockQuantity < 1)
                {
                    // Do nothing, in this case the product is hidden
                }
                else
                    products.Add(product);
            }
        }


        private void GetPopularProducts(int categoryID, ArrayList products)
        {
            CategoryController categoryController = new CategoryController();
            ProductController productController = new ProductController();

            CategoryInfo category = categoryController.GetCategory(categoryID);

            foreach (ProductInfo product in productController.GetPopularProducts(PortalId, categoryID, false))
            {
                if (storeInfo.ProductsBehavior == (int)Behavior.HideProduct && product.StockQuantity < 1)
                {
                    // Do nothing, in this case the product is hidden
                }
                else
                    products.Add(product);
            }

            foreach (CategoryInfo childCategory in categoryController.GetCategories(PortalId, false, categoryID))
            {
                if (childCategory.CategoryID != Null.NullInteger)
                {
                    GetPopularProducts(childCategory.CategoryID, products);
                }
            }
        }

        private void GetPortalPopularProducts(int portalID, ArrayList products)
        {
            ProductController productController = new ProductController();

            foreach (ProductInfo product in productController.GetPortalPopularProducts(portalID, false))
            {
                if (storeInfo.ProductsBehavior == (int)Behavior.HideProduct && product.StockQuantity < 1)
                {
                    // Do nothing, in this case the product is hidden
                }
                else
                    products.Add(product);
            }
        }

        private void GetCategoryProducts(int categoryID, ArrayList products)
        {
            CategoryController categoryController = new CategoryController();
            ProductController productController = new ProductController();

            CategoryInfo category = categoryController.GetCategory(categoryID);

            int sortID;
            if (catalogNav.SortID != Null.NullInteger)
            {
                // Currently selected sort column
                sortID = catalogNav.SortID;
            }
            else
            {
                // Default sort column
                sortID = int.Parse(moduleSettings.CategoryProducts.SortBy);
            }
            string sortDir;
            if (catalogNav.SortDir != Null.NullString)
            {
                // Currently selected sort direction
                sortDir = catalogNav.SortDir;
            }
            else
            {
                // Default sort direction
                sortDir = moduleSettings.CategoryProducts.SortDir;
            }

            foreach (ProductInfo product in productController.GetCategoryProducts(categoryID, false, sortID, sortDir))
            {
                if (storeInfo.ProductsBehavior == (int)Behavior.HideProduct && product.StockQuantity < 1)
                {
                    // Do nothing, in this case the product is hidden
                }
                else
                    products.Add(product);
            }

            if (bool.Parse(moduleSettings.CategoryProducts.SubCategories))
            {
                foreach (CategoryInfo childCategory in categoryController.GetCategories(PortalId, false, categoryID))
                {
                    if (childCategory.CategoryID != Null.NullInteger)
                    {
                        GetCategoryProducts(childCategory.CategoryID, products);
                    }
                }
            }
        }

  private Control LoadProductList(ArrayList products, ProductListTypes listType)
  {
   if (products != null && products.Count > 0)
   {
    ProductList productList = (ProductList)LoadControl(ModulePath + "ProductList.ascx");
    productList.ParentControl = this as PortalModuleBase;
    productList.CategoryID = catalogNav.CategoryID;
                productList.ModuleConfiguration = this.ModuleConfiguration;

    switch (listType)
    {
                    case ProductListTypes.New:
                        productList.ListType = listType;
                        productList.Title = npTitle;
                        productList.ContainerTemplate = moduleSettings.NewProducts.ContainerTemplate;
                        productList.ContainerCssClass = "StoreNewProductList";
                        productList.Template = moduleSettings.NewProducts.Template;
                        productList.ItemCssClass = "StoreNewProductItem";
                        productList.AlternatingItemCssClass = "StoreNewProductAlternatingItem";
                        productList.RowCount = int.Parse(moduleSettings.NewProducts.RowCount);
                        productList.ColumnCount = int.Parse(moduleSettings.NewProducts.ColumnCount);
                        productList.ColumnWidth = int.Parse(moduleSettings.NewProducts.ColumnWidth);
                        productList.Direction = moduleSettings.NewProducts.RepeatDirection;
                        productList.ShowThumbnail = bool.Parse(moduleSettings.NewProducts.ShowThumbnail);
                        productList.ThumbnailWidth = int.Parse(moduleSettings.NewProducts.ThumbnailWidth);
                        productList.ShowDetail = bool.Parse(moduleSettings.General.ShowProductDetail);
                        productList.DetailPage = int.Parse(moduleSettings.NewProducts.DetailPage);
                        break;

     case ProductListTypes.Featured:
                        productList.ListType = listType;
                        productList.Title = fpTitle;
                        productList.ContainerTemplate = moduleSettings.FeaturedProducts.ContainerTemplate;
                        productList.ContainerCssClass = "StoreFeaturedProductList";
      productList.Template = moduleSettings.FeaturedProducts.Template;
                        productList.ItemCssClass = "StoreFeaturedProductItem";
                        productList.AlternatingItemCssClass = "StoreFeaturedProductAlternatingItem";
      productList.RowCount = int.Parse(moduleSettings.FeaturedProducts.RowCount);
      productList.ColumnCount = int.Parse(moduleSettings.FeaturedProducts.ColumnCount);
      productList.ColumnWidth = int.Parse(moduleSettings.FeaturedProducts.ColumnWidth);
                        productList.Direction = moduleSettings.FeaturedProducts.RepeatDirection;
      productList.ShowThumbnail = bool.Parse(moduleSettings.FeaturedProducts.ShowThumbnail);
      productList.ThumbnailWidth = int.Parse(moduleSettings.FeaturedProducts.ThumbnailWidth);
                        productList.ShowDetail = bool.Parse(moduleSettings.General.ShowProductDetail);
      productList.DetailPage = int.Parse(moduleSettings.FeaturedProducts.DetailPage);
      break;

                    case ProductListTypes.MySearchResult:
                        productList.ListType = listType;
                        productList.Title = MSTitle;
                        productList.ContainerTemplate = moduleSettings.MYSEARCHProducts.ContainerTemplate;
                        productList.ContainerCssClass = "StoreFeaturedProductList";
                        productList.Template = moduleSettings.MYSEARCHProducts.Template;
                        productList.ItemCssClass = "StoreFeaturedProductItem";
                        productList.AlternatingItemCssClass = "StoreFeaturedProductAlternatingItem";
                        productList.RowCount = int.Parse(moduleSettings.MYSEARCHProducts.RowCount);
                        productList.ColumnCount = int.Parse(moduleSettings.MYSEARCHProducts.ColumnCount);
                        productList.ColumnWidth = int.Parse(moduleSettings.MYSEARCHProducts.ColumnWidth);
                        productList.Direction = moduleSettings.MYSEARCHProducts.RepeatDirection;
                        productList.ShowThumbnail = bool.Parse(moduleSettings.MYSEARCHProducts.ShowThumbnail);
                        productList.ThumbnailWidth = int.Parse(moduleSettings.MYSEARCHProducts.ThumbnailWidth);
                        productList.ShowDetail = bool.Parse(moduleSettings.General.ShowProductDetail);
                        productList.DetailPage = int.Parse(moduleSettings.MYSEARCHProducts.DetailPage);
                        break;

     case ProductListTypes.Popular:
                        productList.ListType = listType;
                        productList.Title = ppTitle;
                        productList.ContainerTemplate = moduleSettings.PopularProducts.ContainerTemplate;
                        productList.ContainerCssClass = "StorePopularProductList";
      productList.Template = moduleSettings.PopularProducts.Template;
                        productList.ItemCssClass = "StorePopularProductItem";
                        productList.AlternatingItemCssClass = "StorePopularProductAlternatingItem";
      productList.RowCount = int.Parse(moduleSettings.PopularProducts.RowCount);
      productList.ColumnCount = int.Parse(moduleSettings.PopularProducts.ColumnCount);
      productList.ColumnWidth = int.Parse(moduleSettings.PopularProducts.ColumnWidth);
                        productList.Direction = moduleSettings.PopularProducts.RepeatDirection;
      productList.ShowThumbnail = bool.Parse(moduleSettings.PopularProducts.ShowThumbnail);
      productList.ThumbnailWidth = int.Parse(moduleSettings.PopularProducts.ThumbnailWidth);
                        productList.ShowDetail = bool.Parse(moduleSettings.General.ShowProductDetail);
      productList.DetailPage = int.Parse(moduleSettings.PopularProducts.DetailPage);
      break;

     case ProductListTypes.Category:
                        productList.ListType = listType;
                        productList.Title = cpTitle;
                        productList.ContainerTemplate = moduleSettings.CategoryProducts.ContainerTemplate;
                        productList.ContainerCssClass = "StoreCategoryProductList";
      productList.Template = moduleSettings.CategoryProducts.Template;
                        productList.ItemCssClass = "StoreCategoryProductItem";
                        productList.AlternatingItemCssClass = "StoreCategoryProductAlternatingItem";
      productList.RowCount = int.Parse(moduleSettings.CategoryProducts.RowCount);
      productList.ColumnCount = int.Parse(moduleSettings.CategoryProducts.ColumnCount);
      productList.ColumnWidth = int.Parse(moduleSettings.CategoryProducts.ColumnWidth);
                        productList.Direction = moduleSettings.CategoryProducts.RepeatDirection;
      productList.ShowThumbnail = bool.Parse(moduleSettings.CategoryProducts.ShowThumbnail);
      productList.ThumbnailWidth = int.Parse(moduleSettings.CategoryProducts.ThumbnailWidth);
                        productList.ShowDetail = bool.Parse(moduleSettings.General.ShowProductDetail);
      productList.DetailPage = int.Parse(moduleSettings.CategoryProducts.DetailPage);
      break;
    }

    productList.DataSource = products;
    
    return productList;
   }
   else
   {
    return null;
   }
  }

  private Control LoadProductDetail()
  {
   ProductDetail productDetail = (ProductDetail)LoadControl(ModulePath + "ProductDetail.ascx");

   productDetail.ParentControl = this as PortalModuleBase;
            productDetail.ModuleConfiguration = this.ModuleConfiguration;
   productDetail.CategoryID = productInfo.CategoryID;
   productDetail.ShowThumbnail = bool.Parse(moduleSettings.ProductDetail.ShowThumbnail);
   productDetail.ThumbnailWidth = int.Parse(moduleSettings.ProductDetail.ThumbnailWidth);
   productDetail.ShowReviews = bool.Parse(moduleSettings.ProductDetail.ShowReviews);
   productDetail.DataSource = productInfo;

   return productDetail;
  }

  private ArrayList TruncateList(ArrayList list, int maxCount)
  {
   if (list.Count > maxCount)
   {
    list.RemoveRange(maxCount, list.Count - maxCount);
   }
   return list;
  }

        private string SEO(string seoResource, MetaTags metaType)
        {
            string tempResource = seoResource;
            string tempValue = "";
            MatchCollection matchCol = regTokens.Matches(tempResource);

            if (matchCol.Count > 0)
            {
                foreach (Match match in matchCol)
                {
                    switch (metaType)
                    {
                        case MetaTags.Title:
                            switch (match.Value.ToUpper())
                            {
                                case "[PAGETITLE]":
                                    tempValue = BasePage.Title;
                                    break;
                                case "[STORETITLE]":
                                    tempValue = storeInfo.Name;
                                    break;
                                case "[CATEGORYNAME]":
                                    if (catalogNav.CategoryID != Null.NullInteger)
                                    {
                                        tempValue = categoryInfo.CategoryName;
                                    }
                                    else
                                    {
                                        tempValue = "";
                                    }
                                    break;
                                default:
                                    tempValue = match.Value;
                                    break;
                            }
                            break;
                        case MetaTags.Keywords:
                            switch (match.Value.ToUpper())
                            {
                                case "[PAGEKEYWORDS]":
                                    tempValue = BasePage.KeyWords;
                                    break;
                                case "[STOREKEYWORDS]":
                                    tempValue = storeInfo.Keywords;
                                    break;
                                case "[CATEGORYKEYWORDS]":
                                    if (catalogNav.CategoryID != Null.NullInteger)
                                    {
                                        tempValue = categoryInfo.CategoryKeywords;
                                    }
                                    else
                                    {
                                        tempValue = "";
                                    }
                                    break;
                                default:
                                    tempValue = match.Value;
                                    break;
                            }
                            break;
                        case MetaTags.Description:
                            switch (match.Value.ToUpper())
                            {
                                case "[PAGEDESCRIPTION]":
                                    tempValue = BasePage.Description;
                                    break;
                                case "[STOREDESCRIPTION]":
                                    tempValue = storeInfo.Description;
                                    break;
                                case "[CATEGORYDESCRIPTION]":
                                    if (catalogNav.CategoryID != Null.NullInteger)
                                    {
                                        tempValue = categoryInfo.CategoryDescription;
                                    }
                                    else
                                    {
                                        tempValue = "";
                                    }
                                    break;
                                default:
                                    tempValue = match.Value;
                                    break;
                            }
                            break;
                    }
                    tempResource = tempResource.Replace(match.Value, tempValue);
                }
            }
            return tempResource.Trim();
        }

        #endregion

  #region IActionable Members

  public DotNetNuke.Entities.Modules.Actions.ModuleActionCollection ModuleActions
  {
   get
   {
    ModuleActionCollection actions = new ModuleActionCollection();
                if (storeInfo != null)
                {
                    actions.Add(GetNextActionID(), Localization.GetString("AddNewProduct", this.LocalResourceFile), ModuleActionType.AddContent, "", "", EditUrl("EditID", "Product"), false, SecurityAccessLevel.Edit, true, false);
                }
    return actions; 
   }
  }

  #endregion
 }
}


Continue - Part 2