protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request["categoryid"]) || !Int32.TryParse(Request["categoryid"], out _categoryId)) { _categoryId = 0; } category = CategoryService.GetCategory(_categoryId); if (category == null || category.Enabled == false || category.HirecalEnabled == false) { Error404(); return; } ProductsCount = category.GetProductCount(); categoryView.CategoryID = _categoryId; categoryView.Visible = true; pnlSort.Visible = ProductsCount > 0; productView.Visible = ProductsCount > 0; lblCategoryName.Text = _categoryId != 0 ? category.Name : Resource.Client_MasterPage_Catalog; //lblCategoryDescription.Text = category.Description; //imgCategoryImage.ImageUrl = string.IsNullOrEmpty(category.Picture) ? "" : string.Format("{0}", ImageFolders.GetImageCategoryPath(false, category.Picture)); breadCrumbs.Items = CategoryService.GetParentCategories(_categoryId).Select(parent => new BreadCrumbs { Name = parent.Name, Url = "social/catalogsocial.aspx?categoryid=" + parent.CategoryId }).Reverse().ToList(); breadCrumbs.Items.Insert(0, new BreadCrumbs { Name = Resource.Client_MasterPage_MainPage, Url = UrlService.GetAbsoluteLink("social/catalogsocial.aspx") }); SetMeta(category.Meta, category.Name); //перенесено из верстки из-за CustomerSession.CustomerId (Sckeef) defaultDS.TableName = "[Catalog].[Product] LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] LEFT JOIN [Catalog].[Photo] ON [Product].[ProductID] = [Photo].[ObjID] and Type='Product' AND [Main] = 1 inner join Catalog.ProductCategories on ProductCategories.ProductId = [Product].[ProductID] Left JOIN [Catalog].[ProductPropertyValue] ON [Product].[ProductID] = [ProductPropertyValue].[ProductID] LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[EntityID] = [Catalog].[Product].[ProductID] AND [Catalog].[ShoppingCart].[ShoppingCartTypeId] = 3 AND [ShoppingCart].[CustomerID] = @CustomerId Left JOIN [Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=@CustomerId"; defaultDS.AddParamSql(new SqlParam { ParamName = "@CustomerId", ParamValue = CustomerSession.CustomerId.ToString() }); defaultDS.AddCondition("[Settings].[CountCategoriesByProduct]( Product.ProductID) > 0"); var olFilter = new EqualFieldFilter { ParamName = "@OfferListID", Value = CatalogService.CurrentOfferListId.ToString() }; defaultDS.Fields["OfferListID"].Filter = olFilter; if (category.DisplayChildProducts) { var cfilter = new InChildCategoriesFieldFilter { CategoryId = _categoryId.ToString(), ParamName = "@CategoryID" }; defaultDS.Fields["[ProductCategories].[CategoryID]"].Filter = cfilter; } else { var cfilter = new EqualFieldFilter { Value = _categoryId.ToString(), ParamName = "@catalog" }; defaultDS.Fields["[ProductCategories].[CategoryID]"].Filter = cfilter; } var efilter = new EqualFieldFilter { Value = "1", ParamName = "@enabled" }; defaultDS.Fields["Enabled"].Filter = efilter; defaultDS.Fields["HirecalEnabled"].Filter = new EqualFieldFilter { Value = "1", ParamName = "@HirecalEnabled" }; BuildSorting(); }
protected void Page_Load(object sender, EventArgs e) { _paging = new SqlPaging { TableName = "[Catalog].[Product] LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] inner join Catalog.ProductCategories on ProductCategories.ProductId = [Product].[ProductID] Left JOIN [Catalog].[ProductPropertyValue] ON [Product].[ProductID] = [ProductPropertyValue].[ProductID] LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[OfferID] = [Catalog].[Offer].[OfferID] AND [Catalog].[ShoppingCart].[ShoppingCartType] = 3 AND [ShoppingCart].[CustomerID] = @CustomerId Left JOIN [Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=@CustomerId" }; _paging.AddFieldsRange( new List <Field> { new Field { Name = "[Product].[ProductID]", IsDistinct = true }, //new Field {Name = "PhotoName AS Photo"}, new Field { Name = "(CASE WHEN Offer.ColorID is not null THEN (Select Count(PhotoName) From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type) ELSE (Select Count(PhotoName) From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type) END) AS CountPhoto" }, new Field { Name = "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) PhotoName From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type Order By main desc, [Photo].[PhotoSortOrder]) ELSE (Select TOP(1) PhotoName From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type AND [Photo].[Main] = 1) END) AS Photo" }, new Field { Name = "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) [Photo].[Description] From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type Order By main desc, [Photo].[PhotoSortOrder]) ELSE (Select TOP(1) [Photo].[Description] From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type AND [Photo].[Main] = 1) END) AS PhotoDesc" }, new Field { Name = "(select [Settings].[ProductColorsToString]([Product].[ProductID])) as Colors" }, //new Field {Name = "[Photo].[Description] AS PhotoDesc"}, new Field { Name = "[ProductCategories].[CategoryID]", NotInQuery = true }, new Field { Name = "BriefDescription" }, new Field { Name = "Product.ArtNo" }, new Field { Name = "Name" }, new Field { Name = "(CASE WHEN Price=0 THEN 0 ELSE 1 END) as TempSort", Sorting = SortDirection.Descending }, new Field { Name = "Recomended" }, new Field { Name = "Bestseller" }, new Field { Name = "New" }, new Field { Name = "OnSale" }, new Field { Name = "Discount" }, new Field { Name = "Offer.Main", NotInQuery = true }, new Field { Name = "Offer.OfferID" }, new Field { Name = "Offer.Amount" }, new Field { Name = "(CASE WHEN Offer.Amount=0 OR Offer.Amount < IsNull(MinAmount,0) THEN 0 ELSE 1 END) as TempAmountSort", Sorting = SortDirection.Descending }, new Field { Name = "MinAmount" }, new Field { Name = "MaxAmount" }, new Field { Name = "Enabled" }, new Field { Name = "AllowPreOrder" }, new Field { Name = "Ratio" }, new Field { Name = "RatioID" }, new Field { Name = "DateModified" }, new Field { Name = "ShoppingCartItemId" }, new Field { Name = "UrlPath" }, new Field { Name = "[ProductCategories].[SortOrder]" }, new Field { Name = "[ShoppingCart].[CustomerID]", NotInQuery = true }, new Field { Name = "BrandID", NotInQuery = true }, new Field { Name = "Offer.ProductID as Size_ProductID", NotInQuery = true }, new Field { Name = "Offer.ProductID as Color_ProductID", NotInQuery = true }, new Field { Name = "Offer.ProductID as Price_ProductID", NotInQuery = true }, new Field { Name = "Offer.ColorID" }, new Field { Name = "CategoryEnabled", NotInQuery = true }, }); if (SettingsCatalog.ComplexFilter) { _paging.AddFieldsRange(new List <Field> { new Field { Name = "(select max (price) - min (price) from catalog.offer where offer.productid=product.productid) as MultiPrices" }, new Field { Name = "(select min (price) from catalog.offer where offer.productid=product.productid) as Price" }, }); } else { _paging.AddFieldsRange(new List <Field> { new Field { Name = "0 as MultiPrices" }, new Field { Name = "Price" }, }); } _paging.AddParam(new SqlParam { ParameterName = "@CustomerId", Value = CustomerContext.CustomerId.ToString() }); _paging.AddParam(new SqlParam { ParameterName = "@Type", Value = PhotoType.Product.ToString() }); if (string.IsNullOrEmpty(Request["categoryid"]) || !Int32.TryParse(Request["categoryid"], out _categoryId)) { _categoryId = 0; var sbMainPage = StaticBlockService.GetPagePartByKeyWithCache("MainPageSocial"); if (sbMainPage != null && sbMainPage.Enabled) { MainPageText = sbMainPage.Content; } } if (!string.IsNullOrEmpty(MainPageText)) { SetMeta(null, string.Empty); return; } category = CategoryService.GetCategory(_categoryId); if (category == null || category.Enabled == false || category.ParentsEnabled == false) { Error404(); return; } ProductsCount = category.GetProductCount(); categoryView.CategoryID = _categoryId; categoryView.Visible = true; pnlSort.Visible = ProductsCount > 0; productView.Visible = ProductsCount > 0; lblCategoryName.Text = _categoryId != 0 ? category.Name : Resource.Client_MasterPage_Catalog; //lblCategoryDescription.Text = category.Description; //imgCategoryImage.ImageUrl = string.IsNullOrEmpty(category.Picture) ? "" : string.Format("{0}", ImageFolders.GetImageCategoryPath(false, category.Picture)); breadCrumbs.Items = CategoryService.GetParentCategories(_categoryId).Select(parent => new BreadCrumbs { Name = parent.Name, Url = "social/catalogsocial.aspx?categoryid=" + parent.CategoryId }).Reverse().ToList(); breadCrumbs.Items.Insert(0, new BreadCrumbs { Name = Resource.Client_MasterPage_MainPage, Url = UrlService.GetAbsoluteLink("social/catalogsocial.aspx") }); SetMeta(category.Meta, category.Name); if (category.DisplayChildProducts) { var cfilter = new InChildCategoriesFieldFilter { CategoryId = _categoryId.ToString(), ParamName = "@CategoryID" }; _paging.Fields["[ProductCategories].[CategoryID]"].Filter = cfilter; } else { var cfilter = new EqualFieldFilter { Value = _categoryId.ToString(), ParamName = "@catalog" }; _paging.Fields["[ProductCategories].[CategoryID]"].Filter = cfilter; } _paging.Fields["Enabled"].Filter = new EqualFieldFilter { Value = "1", ParamName = "@enabled" };; _paging.Fields["CategoryEnabled"].Filter = new EqualFieldFilter { Value = "1", ParamName = "@CategoryEnabled" }; var logicalFilter = new LogicalFilter { ParamName = "@Main", HideInCustomData = true }; logicalFilter.AddFilter(new EqualFieldFilter { Value = "1", ParamName = "@Main1", HideInCustomData = true }); logicalFilter.AddLogicalOperation("OR"); logicalFilter.AddFilter(new NullFieldFilter { Null = true, ParamName = "@Main2", HideInCustomData = true }); _paging.Fields["Offer.Main"].Filter = logicalFilter; BuildSorting(); }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request["categoryid"]) || !Int32.TryParse(Request["categoryid"], out _categoryId)) { Error404(); } //Changed by Evgeni for Igor(bosch-opt.by) ONLY!! Zapchast redirect to Novost if (_categoryId == 10020) { Response.Redirect(@"https://instrument-opt.by/news/service_and_spare_parts_bosch"); } category = CategoryService.GetCategory(_categoryId); if (category == null || category.Enabled == false || category.HirecalEnabled == false) { Error404(); return; } indepth = Request["indepth"] == "1"; ProductsCount = indepth ? category.TotalProductsCount : category.GetProductCount(); categoryView.CategoryID = _categoryId; categoryView.Visible = category.DisplayStyle == "True" || ProductsCount == 0; pnlSort.Visible = ProductsCount > 0; productView.Visible = ProductsCount > 0; catalogView.CategoryID = _categoryId; filterProperty.CategoryId = _categoryId; filterBrand.CategoryId = _categoryId; filterBrand.InDepth = category.DisplayChildProducts || indepth; filterPrice.CategoryId = _categoryId; filterPrice.InDepth = category.DisplayChildProducts || indepth; lblCategoryName.Text = _categoryId != 0 ? category.Name : Resource.Client_MasterPage_Catalog; breadCrumbs.Items = CategoryService.GetParentCategories(_categoryId).Select(parent => new BreadCrumbs { Name = parent.Name, Url = UrlService.GetLink(ParamType.Category, parent.UrlPath, parent.CategoryId) }).Reverse().ToList(); breadCrumbs.Items.Insert(0, new BreadCrumbs { Name = Resource.Client_MasterPage_MainPage, Url = UrlService.GetAbsoluteLink("/") }); SetMeta(category.Meta, category.Name); //перенесено из верстки из-за CustomerSession.CustomerId (Sckeef) defaultDS.TableName = "[Catalog].[Product] LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] LEFT JOIN [Catalog].[Photo] ON [Product].[ProductID] = [Photo].[ObjId] and Type=@Type AND [Main] = 1 inner join Catalog.ProductCategories on ProductCategories.ProductId = [Product].[ProductID] Left JOIN [Catalog].[ProductPropertyValue] ON [Product].[ProductID] = [ProductPropertyValue].[ProductID] LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[EntityID] = [Catalog].[Product].[ProductID] AND [Catalog].[ShoppingCart].[ShoppingCartTypeId] = 3 AND [ShoppingCart].[CustomerID] = @CustomerId Left JOIN [Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=@CustomerId"; defaultDS.AddParamSql(new SqlParam { ParamName = "@CustomerId", ParamValue = CustomerSession.CustomerId.ToString() }); defaultDS.AddParamSql(new SqlParam { ParamName = "@Type", ParamValue = PhotoType.Product.ToString() }); defaultDS.AddCondition("[Settings].[CountCategoriesByProduct]( Product.ProductID) > 0"); var olFilter = new EqualFieldFilter { ParamName = "@OfferListID", Value = CatalogService.CurrentOfferListId.ToString() }; defaultDS.Fields["OfferListID"].Filter = olFilter; if (category.DisplayChildProducts || indepth) { var cfilter = new InChildCategoriesFieldFilter { CategoryId = _categoryId.ToString(), ParamName = "@CategoryID" }; defaultDS.Fields["[ProductCategories].[CategoryID]"].Filter = cfilter; } else { var cfilter = new EqualFieldFilter { Value = _categoryId.ToString(), ParamName = "@catalog" }; defaultDS.Fields["[ProductCategories].[CategoryID]"].Filter = cfilter; } var efilter = new EqualFieldFilter { Value = "1", ParamName = "@enabled" }; defaultDS.Fields["Enabled"].Filter = efilter; defaultDS.Fields["HirecalEnabled"].Filter = new EqualFieldFilter { Value = "1", ParamName = "@HirecalEnabled" }; BuildSorting(); BuildFilter(); }