protected void Page_Init(object sender, EventArgs e) { _CategoryId = AbleCommerce.Code.PageHelper.GetCategoryId(); _Category = CategoryDataSource.Load(_CategoryId); _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]); _Product = ProductDataSource.Load(_ProductId); if (_Product == null) { Response.Redirect("~/Admin/Catalog/Browse.aspx?CategoryId=" + _CategoryId.ToString()); } _VariantManager = new ProductVariantManager(_ProductId); //BIND GOODS FOR PRODUCT BindDigitalGoodsGrid(); //UPDATE ATTACH BUTTON AllVariants.NavigateUrl += _ProductId.ToString(); //FIGURE OUT PAGING SETTINGS _VariantCount = _VariantManager.CountVariantGrid(); if (_VariantCount > 0) { _WholePages = _VariantCount / _PageSize; _LeftOverItems = _VariantCount % _PageSize; if (_LeftOverItems > 0) { _TotalPages = _WholePages + 1; } else { _TotalPages = _WholePages; } if (_TotalPages == 1) { VariantPager.Visible = false; } //LOAD VIEW STATE LoadCustomViewState(); //SAVE THIS TEXT FOR LATER _DisplayRangeLabelText = DisplayRangeLabel.Text; //INITIALIZE THE GRID BindVariantGrid(); } else { VariantGoodsPanel.Visible = false; } //UPDATE THE CAPTION Caption.Text = string.Format(Caption.Text, _Product.Name); }
protected void Page_Init(object sender, EventArgs e) { _ProductId = AbleCommerce.Code.PageHelper.GetProductId(); _Product = ProductDataSource.Load(_ProductId); _ShowInventory = (_Product.InventoryMode == InventoryMode.Variant && AbleContext.Current.Store.Settings.EnableInventory); if (_Product == null) { Response.Redirect("../../Catalog/Browse.aspx?CategoryId=" + AbleCommerce.Code.PageHelper.GetCategoryId()); } _VariantManager = new ProductVariantManager(_ProductId); if (_VariantManager.Count == 0) { Response.Redirect("Options.aspx?ProductId=" + _ProductId.ToString()); } if (_Product.ProductOptions.Count > ProductVariant.MAXIMUM_ATTRIBUTES) { TooManyVariantsPanel.Visible = true; TooManyVariantsMessage.Text = string.Format(TooManyVariantsMessage.Text, _Product.Name, ProductVariant.MAXIMUM_ATTRIBUTES); } //FIGURE OUT PAGING SETTINGS _VariantCount = _VariantManager.CountVariantGrid(); _WholePages = _VariantCount / _PageSize; _LeftOverItems = _VariantCount % _PageSize; if (_LeftOverItems > 0) { _TotalPages = _WholePages + 1; } else { _TotalPages = _WholePages; } PagerPanel.Visible = (_TotalPages > 1); if (!Page.IsPostBack) { _optionsGridKey = _optionsGridKey + _ProductId; string optionsGridColumns = AbleContext.Current.User.Settings.GetValueByKey(_optionsGridKey); if (!string.IsNullOrEmpty(optionsGridColumns)) { string[] cols = optionsGridColumns.Split(','); if (cols != null) { names = cols.ToList <string>(); foreach (string name in names) { ListItem li = FieldNamesList.Items.FindByValue(name); if (li != null && !li.Selected) { li.Selected = true; } } } } } //LOAD VIEW STATE LoadCustomViewState(); //SAVE THIS TEXT FOR LATER _DisplayRangeLabelText = DisplayRangeLabel.Text; //CONVERT VARIANT FORM DATA TO STRING DICTIONARY ParseFormData(); //INITIALIZE THE GRID BindVariantGrid(); //UPDATE THE CAPTION Caption.Text = string.Format(Caption.Text, _Product.Name); //HIDE THE FIELDS WHEN INVENTORY IS DISABLED FOR VARIANT PRODUCT if (!_ShowInventory) { List <ListItem> removeItems = new List <ListItem>(); for (int i = 0; i < FieldNamesList.Items.Count; i++) { ListItem item = FieldNamesList.Items[i]; if ((item.Value == "InStock") || (item.Value == "Availability") || (item.Value == "LowStock")) { removeItems.Add(item); } } foreach (ListItem li in removeItems) { FieldNamesList.Items.Remove(li); } } }