public ActionResult Index(string slug, int productPageSize = 9, string preContentColumnId = null,
                                  string postContentColumnId       = null)
        {
            var model = LoadCategoryModel(slug, preContentColumnId, postContentColumnId);

            IndexSetup(model);

            var viewName = GetViewName(model);

            if (viewName == null || !viewName.StartsWith("DrillDown"))
            {
                LoadSubCategories(model);
                LoadProducts(model, productPageSize);
            }
            else
            {
                var filter = new CategoryFilterViewModel
                {
                    CategoryId           = model.LocalCategory.Bvin,
                    PageNumber           = 1,
                    IsConsiderSearchable = false
                };
                var sett    = new CategoryModuleSettings(ModuleContext.ModuleId);
                var ddModel = BuildDrillDownModel(filter, sett, 1, productPageSize);
                model.DrillDownJsonModel = JsonConvert.SerializeObject(ddModel);
                model.SortSelectList     = LoadSortSelectList(model.LocalCategory, GetSort(model.LocalCategory), true);
            }

            LogCategoryViewActivity(model.LocalCategory);

            return(View(viewName, model));
        }
Exemplo n.º 2
0
        public ActionResult Index(string slug, int productPageSize = 9, string preContentColumnId = null,
                                  string postContentColumnId       = null)
        {
            var model = LoadCategoryModel(slug, preContentColumnId, postContentColumnId);

            IndexSetup(model);

            var viewName = GetViewName(model);

            if (viewName == null || !viewName.StartsWith("DrillDown"))
            {
                LoadSubCategories(model);
                LoadProducts(model, productPageSize);
            }
            else
            {
                var filter = new CategoryFilterViewModel
                {
                    CategoryId           = model.LocalCategory.Bvin,
                    PageNumber           = 1,
                    IsConsiderSearchable = false,
                    SortOrder            = model.LocalCategory.DisplaySortOrder
                };
                var sett    = new CategoryModuleSettings(ModuleContext.ModuleId);
                var ddModel = BuildDrillDownModel(filter, sett, 1, productPageSize);
                model.DrillDownJsonModel = JsonConvert.SerializeObject(ddModel);
                model.SortSelectList     = LoadSortSelectList(model.LocalCategory, GetSort(model.LocalCategory), true);
            }

            if (AuthorizedToEditCatalog())
            {
                if (!string.IsNullOrEmpty(model.LocalCategory.Bvin))
                {
                    model.CategoryAnalyticsUrl = string.Format(CategoryAnalyticsUrlFormat, model.LocalCategory.Bvin);
                    model.CategoryEditUrl      = string.Format(CategoryEditUrlFormat, model.LocalCategory.Bvin);
                }
                else
                {
                    model.CategoriesManagementUrl = CategoriesAdminUrl;
                    model.ProductsManagementUrl   = ProductsAdminUrl;
                }

                model.StoreAdminUrl           = DashboardAdminUrl;
                model.AuthorizedToEditCatalog = true;
            }
            else
            {
                model.AuthorizedToEditCatalog = false;
            }

            LogCategoryViewActivity(model.LocalCategory);

            return(View(viewName, model));
        }
        public ActionResult DrillDown(CategoryFilterViewModel filter)
        {
            var sett       = new CategoryModuleSettings(filter.ModuleId);
            var pageNumber = filter.PageNumber ?? 1;
            var pageSize   = sett.PageSize;

            filter.IsConsiderSearchable = false;

            var model = BuildDrillDownModel(filter, sett, pageNumber, pageSize);

            return(Json(model));
        }
        private void FillSortingCheckboxList()
        {
            var categorySettings = new CategoryModuleSettings(ModuleId);
            var sortOptions      = categorySettings.SortOrderOptions;
            var sortOrders       = HccApp.CatalogServices.GetCategorySortOrderList();

            foreach (var sortOrder in sortOrders)
            {
                SortingOptionsCheckBoxList.Items.Add(new ListItem
                {
                    Value    = ((int)sortOrder).ToString(),
                    Text     = LocalizeString("SortOrder_" + sortOrder),
                    Selected = sortOptions.Contains(sortOrder)
                });
            }
        }
        public override void UpdateSettings()
        {
            var categorySettings = new CategoryModuleSettings(ModuleId);
            var controller       = new ModuleController();

            controller.UpdateModuleSetting(ModuleId, "Slug", CategoryComboBox.SelectedValue);
            controller.UpdateModuleSetting(ModuleId, "View", ViewComboBox.SelectedValue);
            controller.UpdateModuleSetting(ModuleId, "ProductPageSize", ProductPageSizeTextBox.Text);
            controller.UpdateModuleSetting(ModuleId, "DefaultPreContentColumnId", ddlPreContentColumnId.SelectedValue);
            controller.UpdateModuleSetting(ModuleId, "DefaultPostContentColumnId", ddlPostContentColumnId.SelectedValue);
            controller.UpdateModuleSetting(ModuleId, "ShowManufactures", ShowManufacturesCheckBox.Checked.ToString());
            controller.UpdateModuleSetting(ModuleId, "ShowVendors", ShowVendorsCheckBox.Checked.ToString());

            var qOptions = SortingOptionsCheckBoxList.Items
                           .OfType <ListItem>()
                           .Where(i => i.Selected)
                           .Select(i => (CategorySortOrder)Convert.ToInt32(i.Value));

            categorySettings.SortOrderOptions = qOptions.ToList();
        }
        private List <SelectListItem> LoadSortSelectList(Category cat, CategorySortOrder sortOrder,
                                                         bool isDrillDown = false)
        {
            var categorySettings = new CategoryModuleSettings(ModuleContext.ModuleId);
            var items            = new List <SelectListItem>();
            var sortOrders       = categorySettings.SortOrderOptions;

            sortOrders.Insert(0, CategorySortOrder.ManualOrder);

            foreach (var order in sortOrders)
            {
                var url = !isDrillDown
                    ? BuildUrlForCategory(cat, null, new { sort = (int)order })
                    : ((int)order).ToString();

                var text = Localization.GetString(string.Format("CategorySortOrder{0}", order));
                items.Add(new SelectListItem {
                    Selected = sortOrder == order, Text = text, Value = url
                });
            }

            return(items);
        }
        private DrillDownJsonModel BuildDrillDownModel(CategoryFilterViewModel filter, CategoryModuleSettings sett,
                                                       int pageNumber, int pageSize)
        {
            var model    = new DrillDownJsonModel();
            var manager  = new SearchManager(HccApp.CurrentRequestContext);
            var queryAdv = BuildDrillDownQuery(filter);
            var result   = manager.DoProductSearch(HccApp.CurrentStore.Id, null, queryAdv, pageNumber, pageSize);

            model.Manufacturers = sett.ShowManufacturers
                ? ToCheckBoxItems(result.Manufacturers, result.SelectedManufacturers, result.TotalCount)
                : new List <CheckboxFacetItem>();
            model.Vendors = sett.ShowVendors
                ? ToCheckBoxItems(result.Vendors, result.SelectedVendors, result.TotalCount)
                : new List <CheckboxFacetItem>();

            model.SubCategories = LoadDrillDownCategories(filter.CategoryId);
            model.SortOrder     = queryAdv.SortOrder;

            LoadDrillDownModel(model, pageNumber, pageSize, result);
            return(model);
        }