protected SpecificationAttributeOptionFilterCollection getAlreadyFilteredSpecs()
        {
            SpecificationAttributeOptionFilterCollection result = new SpecificationAttributeOptionFilterCollection();

            string[] queryStringParams = getAlreadyFilteredSpecsQueryStringParams();
            foreach (string qsp in queryStringParams)
            {
                int id = 0;
                int.TryParse(Request.QueryString[qsp], out id);
                SpecificationAttributeOption sao = SpecificationAttributeManager.GetSpecificationAttributeOptionByID(id);
                if (sao != null)
                {
                    SpecificationAttribute sa = sao.SpecificationAttribute;
                    if (sa != null)
                    {
                        result.Add(new SpecificationAttributeOptionFilter
                        {
                            SpecificationAttributeID   = sa.SpecificationAttributeID,
                            SpecificationAttributeName = sa.Name,
                            DisplayOrder = sa.DisplayOrder,
                            SpecificationAttributeOptionID   = sao.SpecificationAttributeOptionID,
                            SpecificationAttributeOptionName = sao.Name
                        });
                    }
                }
            }

            return(result);
        }
Example #2
0
        protected void OnSpecificationAttributeOptionsDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int saoID = (int)grdSpecificationAttributeOptions.DataKeys[e.RowIndex]["SpecificationAttributeOptionID"];
            SpecificationAttributeOption sao = SpecificationAttributeManager.GetSpecificationAttributeOptionByID(saoID);

            if (sao != null)
            {
                SpecificationAttributeManager.DeleteSpecificationAttributeOption(sao.SpecificationAttributeOptionID);
                string paletteFolderPath = Server.MapPath("~/images/palette/");
                ColorManager.DeleteColor(sao.Name, paletteFolderPath);
                BindData();
            }
        }
Example #3
0
        public static List <ColorItem> GetColorsBySAOID(List <int> specificationAttributeOptionIDs)
        {
            List <ColorItem> colors = new List <ColorItem>();

            foreach (var id in specificationAttributeOptionIDs)
            {
                SpecificationAttributeOption sao = SpecificationAttributeManager.GetSpecificationAttributeOptionByID(id);
                ColorItem colorItem = ColorManager.GetColorByColorName(sao.Name);
                if (colorItem != null)
                {
                    colors.Add(colorItem);
                }
            }

            return(colors);
        }
Example #4
0
        protected void gvProductSpecificationAttributes_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ProductSpecificationAttribute productSpecificationAttribute = (ProductSpecificationAttribute)e.Row.DataItem;

                Button btnUpdate = e.Row.FindControl("btnUpdate") as Button;
                if (btnUpdate != null)
                {
                    btnUpdate.CommandArgument = e.Row.RowIndex.ToString();
                }

                SpecificationAttributeOption sao      = SpecificationAttributeManager.GetSpecificationAttributeOptionByID(productSpecificationAttribute.SpecificationAttributeOptionID);
                SpecificationAttribute       sa       = SpecificationAttributeManager.GetSpecificationAttributeByID(sao.SpecificationAttributeID);
                Literal lblSpecificationAttributeName = e.Row.FindControl("lblSpecificationAttributeName") as Literal;
                lblSpecificationAttributeName.Text = sa.Name;

                DropDownList ddlSpecificationAttributeOption = e.Row.FindControl("ddlSpecificationAttributeOption") as DropDownList;
                ddlSpecificationAttributeOption.Items.Clear();
                SpecificationAttributeOptionCollection saoCol = SpecificationAttributeManager.GetSpecificationAttributeOptionsBySpecificationAttribute(sao.SpecificationAttributeID);
                foreach (SpecificationAttributeOption sao1 in saoCol)
                {
                    ListItem item = new ListItem(sao1.Name, sao1.SpecificationAttributeOptionID.ToString());
                    ddlSpecificationAttributeOption.Items.Add(item);
                    if (productSpecificationAttribute.SpecificationAttributeOptionID == sao1.SpecificationAttributeOptionID)
                    {
                        item.Selected = true;
                    }
                }

                CheckBox chkAllowFiltering = e.Row.FindControl("chkAllowFiltering") as CheckBox;
                chkAllowFiltering.Checked = productSpecificationAttribute.AllowFiltering;

                CheckBox chkShowOnProductPage = e.Row.FindControl("chkShowOnProductPage") as CheckBox;
                chkShowOnProductPage.Checked = productSpecificationAttribute.ShowOnProductPage;
            }
        }
Example #5
0
        protected void OnSpecificationAttributeOptionsCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "UpdateOption")
            {
                int            index           = Convert.ToInt32(e.CommandArgument);
                GridViewRow    row             = grdSpecificationAttributeOptions.Rows[index];
                SimpleTextBox  txtName         = row.FindControl("txtOptionName") as SimpleTextBox;
                NumericTextBox txtDisplayOrder = row.FindControl("txtOptionDisplayOrder") as NumericTextBox;
                HiddenField    hfSpecificationAttributeOptionID = row.FindControl("hfSpecificationAttributeOptionID") as HiddenField;

                string name         = txtName.Text;
                int    displayOrder = txtDisplayOrder.Value;
                int    saoID        = int.Parse(hfSpecificationAttributeOptionID.Value);

                SpecificationAttributeOption sao = SpecificationAttributeManager.GetSpecificationAttributeOptionByID(saoID);
                if (sao != null)
                {
                    SpecificationAttributeManager.UpdateSpecificationAttributeOptions(saoID, SpecificationAttributeID, name, displayOrder);
                    ColorManager.UpdateColor(sao.Name, name);
                }

                BindData();
            }
        }
Example #6
0
        public void CreateCompareTable()
        {
            this.tblCompareProducts.Rows.Clear();
            this.tblCompareProducts.Width = "100%";
            ProductCollection compareProducts = ProductManager.GetCompareProducts();

            if (compareProducts.Count > 0)
            {
                HtmlTableRow headerRow = new HtmlTableRow();
                this.AddCell(headerRow, "&nbsp;");
                HtmlTableRow productNameRow = new HtmlTableRow();
                this.AddCell(productNameRow, "&nbsp;");
                HtmlTableRow  priceRow = new HtmlTableRow();
                HtmlTableCell cell     = new HtmlTableCell();
                cell.InnerText = GetLocaleResourceString("Products.CompareProductsPrice");
                cell.Align     = "center";
                priceRow.Cells.Add(cell);

                List <int> allAttributeIDs = new List <int>();
                foreach (Product product in compareProducts)
                {
                    ProductSpecificationAttributeCollection productSpecificationAttributes = SpecificationAttributeManager.GetProductSpecificationAttributesByProductID(product.ProductID, null, true);
                    foreach (ProductSpecificationAttribute attribute in productSpecificationAttributes)
                    {
                        if (!allAttributeIDs.Contains(attribute.SpecificationAttributeOptionID))
                        {
                            allAttributeIDs.Add(attribute.SpecificationAttributeOptionID);
                        }
                    }
                }

                foreach (Product product in compareProducts)
                {
                    HtmlTableCell      headerCell        = new HtmlTableCell();
                    HtmlGenericControl headerCellDiv     = new HtmlGenericControl("div");
                    Button             btnRemoveFromList = new Button();
                    btnRemoveFromList.ToolTip          = GetLocaleResourceString("Products.CompareProductsRemoveFromList");
                    btnRemoveFromList.Text             = GetLocaleResourceString("Products.CompareProductsRemoveFromList");
                    btnRemoveFromList.CommandName      = "Remove";
                    btnRemoveFromList.Command         += new CommandEventHandler(this.btnRemoveFromList_Command);
                    btnRemoveFromList.CommandArgument  = product.ProductID.ToString();
                    btnRemoveFromList.CausesValidation = false;
                    btnRemoveFromList.CssClass         = "removeButton";
                    btnRemoveFromList.ID = "btnRemoveFromList" + product.ProductID.ToString();
                    headerCellDiv.Controls.Add(btnRemoveFromList);

                    HtmlGenericControl productImagePanel = new HtmlGenericControl("p");
                    productImagePanel.Attributes.Add("align", "center");

                    HtmlImage productImage = new HtmlImage();
                    productImage.Border = 0;
                    //productImage.Align = "center";
                    productImage.Alt = "Product image";
                    ProductPictureCollection productPictures = product.ProductPictures;
                    if (productPictures.Count > 0)
                    {
                        productImage.Src = PictureManager.GetPictureUrl(productPictures[0].Picture, SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 125), true);
                    }
                    else
                    {
                        productImage.Src = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 125));
                    }
                    productImagePanel.Controls.Add(productImage);

                    headerCellDiv.Controls.Add(productImagePanel);



                    headerCell.Controls.Add(headerCellDiv);
                    headerRow.Cells.Add(headerCell);
                    HtmlTableCell productNameCell = new HtmlTableCell();
                    HyperLink     productLink     = new HyperLink();
                    productLink.Text        = Server.HtmlEncode(product.Name);
                    productLink.NavigateUrl = SEOHelper.GetProductURL(product);
                    productLink.Attributes.Add("class", "link");
                    productNameCell.Align = "center";
                    productNameCell.Controls.Add(productLink);
                    productNameRow.Cells.Add(productNameCell);
                    HtmlTableCell priceCell = new HtmlTableCell();
                    priceCell.Align = "center";
                    ProductVariantCollection productVariantCollection = product.ProductVariants;
                    if (productVariantCollection.Count > 0)
                    {
                        ProductVariant productVariant = productVariantCollection[0];

                        //decimal oldPrice = productVariant.OldPrice;
                        //decimal oldPriceConverted = CurrencyManager.ConvertCurrency(oldPrice, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                        decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                        decimal finalPriceWithoutDiscount     = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                        priceCell.InnerText = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                    }
                    priceRow.Cells.Add(priceCell);
                }
                productNameRow.Attributes.Add("class", "productName");
                priceRow.Attributes.Add("class", "productPrice");
                this.tblCompareProducts.Rows.Add(headerRow);
                this.tblCompareProducts.Rows.Add(productNameRow);
                this.tblCompareProducts.Rows.Add(priceRow);

                if (allAttributeIDs.Count > 0)
                {
                    foreach (int specificationAttributeID in allAttributeIDs)
                    {
                        //SpecificationAttribute attribute = SpecificationAttributeManager.GetSpecificationAttributeByID(specificationAttributeID);
                        SpecificationAttributeOption attributeOption = SpecificationAttributeManager.GetSpecificationAttributeOptionByID(specificationAttributeID);
                        HtmlTableRow productRow = new HtmlTableRow();
                        this.AddCell(productRow, Server.HtmlEncode(attributeOption.SpecificationAttribute.Name)).Align = "left";

                        foreach (Product product2 in compareProducts)
                        {
                            HtmlTableCell productCell = new HtmlTableCell();
                            {
                                ProductSpecificationAttributeCollection productSpecificationAttributes2 = SpecificationAttributeManager.GetProductSpecificationAttributesByProductID(product2.ProductID, null, true);
                                foreach (ProductSpecificationAttribute attribute2 in productSpecificationAttributes2)
                                {
                                    if (attributeOption.SpecificationAttributeOptionID == attribute2.SpecificationAttributeOptionID)
                                    {
                                        productCell.InnerHtml = (!String.IsNullOrEmpty(attribute2.SpecificationAttributeOption.Name)) ? Server.HtmlEncode(attribute2.SpecificationAttributeOption.Name) : "&nbsp;";
                                    }
                                }
                            }
                            productCell.Align  = "center";
                            productCell.VAlign = "top";
                            productRow.Cells.Add(productCell);
                        }
                        this.tblCompareProducts.Rows.Add(productRow);
                    }
                }
                string width = Math.Round((decimal)(90M / compareProducts.Count), 0).ToString() + "%";
                for (int i = 0; i < this.tblCompareProducts.Rows.Count; i++)
                {
                    HtmlTableRow row = this.tblCompareProducts.Rows[i];
                    for (int j = 1; j < row.Cells.Count; j++)
                    {
                        if (j == (row.Cells.Count - 1))
                        {
                            row.Cells[j].Style.Add("width", width);
                            row.Cells[j].Style.Add("text-align", "center");
                        }
                        else
                        {
                            row.Cells[j].Style.Add("width", width);
                            row.Cells[j].Style.Add("text-align", "center");
                        }
                    }
                }
            }
            else
            {
                btnClearCompareProductsList.Visible = false;
                tblCompareProducts.Visible          = false;
            }
        }