protected void Page_PreRender(object sender, EventArgs e) { _paging.CurrentPageIndex = paging.CurrentPage != 0 ? paging.CurrentPage : 1; _paging.ItemsPerPage = paging.CurrentPage != 0 ? SettingsCatalog.ProductsPerPage : int.MaxValue; var totalCount = _paging.TotalRowsCount; paging.TotalPages = _paging.PageCount(totalCount); if (totalCount != 0 && paging.TotalPages < paging.CurrentPage || paging.CurrentPage < 0) { Error404(); return; } if (Request["ajax"] == "1") { Response.Clear(); Response.ContentType = "application/json"; var prices = _paging.GetCustomData( "min(Price - Price * discount/100) as PriceFrom, max(Price - Price * discount/100) as PriceTo", string.Empty, reader => new { From = SQLDataHelper.GetFloat(reader, "PriceFrom"), To = SQLDataHelper.GetFloat(reader, "PriceTo"), }, false).First(); var res = JsonConvert.SerializeObject(new { ProductsCount = totalCount, AvaliblePriceFrom = Math.Floor(prices.From / CurrencyService.CurrentCurrency.Value), AvaliblePriceTo = Math.Ceiling(prices.To / CurrencyService.CurrentCurrency.Value), AvalibleBrands = filterBrand.AvalibleBrandIDs, }); Response.Write(res); Response.End(); return; } var data = _paging.PageItems; productView.DataSource = data; productView.DataBind(); bool exluderingFilters = SettingsCatalog.ExluderingFilters; filterBrand.AvalibleBrandIDs = exluderingFilters ? _paging.GetCustomData("BrandID", " AND BrandID is not null", reader => SQLDataHelper.GetInt(reader, "BrandID"), true) : null; }
protected void Page_Prerender(object sender, EventArgs e) { _paging.CurrentPageIndex = paging.CurrentPage != 0 ? paging.CurrentPage : 1; _paging.ItemsPerPage = paging.CurrentPage != 0 ? SettingsCatalog.ProductsPerPage : int.MaxValue; var totalCount = _paging.TotalRowsCount; paging.TotalPages = _paging.PageCount(totalCount); if (totalCount != 0 && paging.TotalPages < paging.CurrentPage || paging.CurrentPage < 0) { Error404(); return; } // if we get request from ajax filter if (Request["ajax"] == "1") { var prices = _paging.GetCustomData( "min(Price - Price * discount/100) as PriceFrom, max(Price - Price * discount/100) as PriceTo", string.Empty, reader => new { From = SQLDataHelper.GetFloat(reader, "PriceFrom"), To = SQLDataHelper.GetFloat(reader, "PriceTo") }, false ).First(); Response.Clear(); Response.ContentType = "application/json"; var res = JsonConvert.SerializeObject(new { ProductsCount = totalCount, AvaliblePriceFrom = Math.Floor(prices.From / CurrencyService.CurrentCurrency.Value), AvaliblePriceTo = Math.Ceiling(prices.To / CurrencyService.CurrentCurrency.Value), }); Response.Write(res); Response.End(); return; } if (!string.IsNullOrEmpty(Page.Request["name"]) && string.IsNullOrEmpty(Page.Request["ignorelog"])) { var url = Page.Request.Url.ToString(); url = url.Substring(url.LastIndexOf("/"), url.Length - url.LastIndexOf("/")); StatisticService.AddSearchStatistic( url, Page.Request["name"], string.Format(Resource.Client_Search_SearchIn, ddlCategory.SelectedItem.Text, filterPrice.CurValMin, string.IsNullOrEmpty(Request["priceto"]) ? "∞" : filterPrice.CurValMax.ToString()), totalCount, CustomerContext.CurrentCustomer.Id); } //filterPrice.Min = prices.Key / CurrencyService.CurrentCurrency.Value; //filterPrice.Max = prices.Value / CurrencyService.CurrentCurrency.Value; var data = _paging.PageItems; vProducts.DataSource = data; vProducts.ViewMode = productViewChanger.SearchViewMode; vProducts.DataBind(); int itemsCount = totalCount; lItemsCount.Text = string.Format("{0} {1}", itemsCount, Strings.Numerals(itemsCount, Resource.Client_Searsh_NoResults, Resource.Client_Searsh_1Result, Resource.Client_Searsh_2Results, Resource.Client_Searsh_5Results)); pnlSort.Visible = itemsCount > 0; if (GoogleTagManager.Enabled) { var tagManager = ((AdvantShopMasterPage)Master).TagManager; tagManager.PageType = GoogleTagManager.ePageType.searchresults; tagManager.ProdIds = new List <string>(); foreach (DataRow row in data.Rows) { tagManager.ProdIds.Add((string)row["ArtNo"]); } } }
protected void Page_PreRender(object sender, EventArgs e) { _paging.ItemsPerPage = paging.CurrentPage != 0 ? SettingsCatalog.ProductsPerPage : int.MaxValue; _paging.CurrentPageIndex = paging.CurrentPage != 0 ? paging.CurrentPage : 1; var totalCount = _paging.TotalRowsCount; lTotalItems.Text = string.Format(Resource.Client_Catalog_ItemsFound, totalCount); paging.TotalPages = _paging.PageCount(totalCount); if ((paging.TotalPages < paging.CurrentPage && paging.CurrentPage > 1) || paging.CurrentPage < 0) { Error404(); return; } // if we get request from ajax filter if (Request["ajax"] == "1") { Response.Clear(); Response.ContentType = "application/json"; var prices = _paging.GetCustomData( "min(Price - Price * discount/100) as PriceFrom, max(Price - Price * discount/100) as PriceTo", string.Empty, reader => new { From = SQLDataHelper.GetFloat(reader, "PriceFrom"), To = SQLDataHelper.GetFloat(reader, "PriceTo"), }, false ).First(); var res = JsonConvert.SerializeObject(new { ProductsCount = totalCount, AvalibleProperties = filterProperty.AvaliblePropertyIDs, AvalibleBrands = filterBrand.AvalibleBrandIDs, AvaliblePriceFrom = Math.Floor(prices.From / CurrencyService.CurrentCurrency.Value), AvaliblePriceTo = Math.Ceiling(prices.To / CurrencyService.CurrentCurrency.Value), }); Response.Write(res); Response.End(); return; } var data = _paging.PageItems; productView.DataSource = data; productView.DataBind(); bool exluderingFilters = SettingsCatalog.ExluderingFilters; filterProperty.AvaliblePropertyIDs = exluderingFilters ? _paging.GetCustomData("PropertyValueID", " AND PropertyValueID is not null", reader => SQLDataHelper.GetInt(reader, "PropertyValueID"), true, "Left JOIN [Catalog].[ProductPropertyValue] ON [Product].[ProductID] = [ProductPropertyValue].[ProductID]") : null; filterBrand.AvalibleBrandIDs = exluderingFilters ? _paging.GetCustomData("BrandID", " AND BrandID is not null", reader => SQLDataHelper.GetInt(reader, "BrandID"), true) : null; if (SettingsCatalog.ShowSizeFilter) { filterSize.AvalibleSizesIDs = exluderingFilters ? _paging.GetCustomData("sizeOffer.SizeID", " AND sizeOffer.SizeID is not null", reader => SQLDataHelper.GetInt(reader, "SizeID"), true, "Left JOIN [Catalog].[Offer] as sizeOffer ON [Product].[ProductID] = [sizeOffer].[ProductID]") : null; } if (SettingsCatalog.ShowColorFilter) { filterColor.AvalibleColorsIDs = exluderingFilters ? _paging.GetCustomData("colorOffer.ColorID", " AND colorOffer.ColorID is not null", reader => SQLDataHelper.GetInt(reader, "ColorID"), true, "Left JOIN [Catalog].[Offer] as colorOffer ON [Product].[ProductID] = [colorOffer].[ProductID]") : null; } if (GoogleTagManager.Enabled) { var tagManager = ((AdvantShopMasterPage)Master).TagManager; tagManager.PageType = GoogleTagManager.ePageType.category; tagManager.CatCurrentId = Category.ID; tagManager.CatCurrentName = Category.Name; tagManager.CatParentId = Category.ParentCategory.ID; tagManager.CatParentName = Category.ParentCategory.Name; tagManager.ProdIds = new List <string>(); foreach (DataRow row in data.Rows) { tagManager.ProdIds.Add((string)row["ArtNo"]); } } }