Exemplo n.º 1
0
 public ProductFactory(ProductAttributeCollection productAttributes,
                       CatalogInventoryCollection catalogInventories, ProductOptionCollection productOptions, ProductVariantCollection productVariantCollection)
 {
     _productVariantFactory    = new ProductVariantFactory(productAttributes, catalogInventories);
     _productOptionCollection  = productOptions;
     _productVariantCollection = productVariantCollection;
 }
Exemplo n.º 2
0
        protected void BindGrid()
        {
            ProductVariantCollection productVariants = ProductManager.GetLowStockProductVariants();

            gvProductVariants.DataSource = productVariants;
            gvProductVariants.DataBind();
        }
Exemplo n.º 3
0
        public Product(IProductVariant variant, ProductOptionCollection productOptions, ProductVariantCollection productVariants)
        {
            Mandate.ParameterNotNull(variant, "variantMaster");
            Mandate.ParameterNotNull(productOptions, "optionCollection");
            Mandate.ParameterNotNull(productVariants, "productVariants");

            _variant = variant;
            _productOptions = productOptions;
            _productVariants = productVariants;
        }
        private void BindData()
        {
            Product product = ProductManager.GetProductByID(this.ProductID);

            if (product != null)
            {
                ProductVariantCollection productVariants = product.ProductVariants;
                gvProductVariants.DataSource = productVariants;
                gvProductVariants.DataBind();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the <see cref="ProductVariantCollection"/> for a given product.
        /// </summary>
        /// <param name="productKey">
        /// The product key.
        /// </param>
        /// <returns>
        /// The <see cref="ProductVariantCollection"/>.
        /// </returns>
        public ProductVariantCollection GetProductVariantCollection(Guid productKey)
        {
            var collection = new ProductVariantCollection();
            var variants   = GetByProductKey(productKey);

            foreach (var variant in variants.Where(variant => variant != null))
            {
                collection.Add(variant);
            }

            return(collection);
        }
Exemplo n.º 6
0
 private ProductVariant GetVariant(ProductVariantCollection productVariants)
 {
     productVariants.Sort(new GenericComparer <ProductVariant>
                              ("Price", GenericComparer <ProductVariant> .SortOrder.Ascending));
     if (productVariants.Count > 0)
     {
         return(productVariants[0]);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 7
0
        private string GenerateListOfRestrictedProductVariants(ProductVariantCollection productVariants)
        {
            StringBuilder result = new StringBuilder();

            for (int i = 0; i < productVariants.Count; i++)
            {
                ProductVariant pv = productVariants[i];
                result.Append(pv.ProductVariantId.ToString());
                if (i != productVariants.Count - 1)
                {
                    result.Append(", ");
                }
            }
            return(result.ToString());
        }
Exemplo n.º 8
0
        private ProductVariantCollection GetProductVariantCollection(Guid productKey)
        {
            var collection = new ProductVariantCollection();
            var query      = Querying.Query <IProductVariant> .Builder.Where(x => x.ProductKey == productKey && ((ProductVariant)x).Master == false);

            var variants = _productVariantRepository.GetByQuery(query);

            foreach (var variant in variants)
            {
                if (variant != null) // todo why is this need?
                {
                    collection.Add(variant);
                }
            }
            return(collection);
        }
Exemplo n.º 9
0
        protected void BindData()
        {
            Product product = ProductManager.GetProductByID(ProductID);

            if (product != null)
            {
                ProductVariantCollection productVariants = product.ProductVariants;
                if (productVariants.Count > 0)
                {
                    rptVariants.DataSource = productVariants;
                    rptVariants.DataBind();
                }
                else
                {
                    this.Visible = false;
                }
            }
            else
            {
                this.Visible = false;
            }
        }
        private void BindingCatalog()
        {
            if (ProductId == 0)
            {
                pnlMessage.Visible      = true;
                updatepnCatalog.Visible = false;
                return;
            }
            else
            {
                Product product = ProductManager.GetProductById(this.ProductId);
                if (product != null)
                {
                    ltBlurb.Text = product.FullDescription;

                    //load product variants
                    ProductVariantCollection productVariants = product.ProductVariants;
                    gvProductVariants.DataSource = productVariants;
                    gvProductVariants.DataBind();
                    if (productVariants.Count > 1)
                    {
                        lblFScprodcode.Text = productVariants[1].SKU.ToString();// FSCprodcode1 mapped from SKU of second variant
                    }
                    CatalogBiz  cBiz = new CatalogBiz();
                    lwg_Catalog c    = cBiz.GetByID(ProductId);
                    if (c != null)
                    {
                        FillData(c);
                        btnAdd.Text = "Update";
                    }
                    else
                    {
                        ClearData();
                        btnAdd.Text = "Add";
                    }
                }
            }
        }
Exemplo n.º 11
0
        private void BindData()
        {
            if (product != null)
            {
                string productURL = SEOHelper.GetProductURL(product);

                hlProduct.Text = Server.HtmlEncode(product.Name);

                ProductPictureCollection productPictures = product.ProductPictures;
                if (productPictures.Count > 0)
                {
                    hlImageLink.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].Picture, ProductImageSize, true);
                    hlImageLink.ToolTip  = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name);
                    hlImageLink.Text     = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                }
                else
                {
                    hlImageLink.ImageUrl = PictureManager.GetDefaultPictureUrl(this.ProductImageSize);
                    hlImageLink.ToolTip  = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name);
                    hlImageLink.Text     = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                }
                hlImageLink.NavigateUrl = productURL;

                lShortDescription.Text = product.ShortDescription;

                ProductVariantCollection productVariantCollection = product.ProductVariants;

                if (productVariantCollection.Count > 0)
                {
                    if (!product.HasMultipleVariants)
                    {
                        ProductVariant productVariant = productVariantCollection[0];

                        decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));

                        lblPrice.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscountBase);
                        if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD")
                        {
                            lblPrice.Text += "$";
                        }
                    }
                    else
                    {
                        ProductVariant productVariant = product.MinimalPriceProductVariant;
                        if (productVariant != null)
                        {
                            decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                            decimal fromPrice     = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                            lblPrice.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice));
                        }
                    }
                }
                else
                {
                    lblPrice.Visible = false;
                }

                #region scjaarge's change
                if (!lblPrice.Visible || lblPrice.Text.Trim() == string.Empty)
                {
                    litOrderOrNa.Text = "Нет в наличии";
                }
                #endregion scjaarge's change
            }
        }
Exemplo n.º 12
0
        private string createPricelistContents()
        {
            string strContents = "";

            ProductVariantCollection productVariants = new ProductVariantCollection();
            bool blnOverrideAdjustment = this.OverrideIndivAdjustment;

            switch (this.ExportMode)
            {
            case PriceListExportModeEnum.All:
            {
                blnOverrideAdjustment = true;
                foreach (Product product in ProductManager.GetAllProducts(false))
                {
                    productVariants.AddRange(ProductManager.GetProductVariantsByProductID(product.ProductID, false));
                }
            }
            break;

            case PriceListExportModeEnum.AssignedProducts:
            {
                productVariants = ProductManager.GetProductVariantsByPricelistID(this.PricelistID);
            }
            break;

            default:
                break;
            }

            // create new file
            // write header, if provided
            if (!String.IsNullOrEmpty(this.Header))
            {
                strContents += this.Header;
                if (!this.Header.EndsWith("\n"))
                {
                    strContents += "\n";
                }
            }

            // write body
            foreach (ProductVariant productVariant in productVariants)
            {
                // calculate price adjustments
                decimal newPrice = decimal.Zero;

                // if export mode is all, then calculate price
                if (blnOverrideAdjustment)
                {
                    newPrice = getAdjustedPrice(productVariant.Price, this.PriceAdjustmentType, PriceAdjustment);
                }
                else
                {
                    ProductVariantPricelist productVariantPricelist = ProductManager.GetProductVariantPricelist(productVariant.ProductVariantID, this.PricelistID);
                    if (productVariantPricelist != null)
                    {
                        newPrice = getAdjustedPrice(productVariant.Price, productVariantPricelist.PriceAdjustmentType, productVariantPricelist.PriceAdjustment);
                    }
                }
                strContents += replaceMessageTemplateTokens(productVariant, this.Body,
                                                            this.FormatLocalization, new System.Collections.Specialized.NameValueCollection(), AffiliateID, newPrice);
                if (!this.Body.EndsWith("\n"))
                {
                    strContents += "\n";
                }
            }

            // write footer, if provided
            if (!String.IsNullOrEmpty(this.Footer))
            {
                strContents += this.Header;
                if (!this.Footer.EndsWith("\n"))
                {
                    strContents += "\n";
                }
            }

            return(strContents);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Generate froogle feed
        /// </summary>
        /// <param name="stream">Stream</param>
        public static void GenerateFeed(Stream stream)
        {
            const string googleBaseNamespace = "http://base.google.com/ns/1.0";

            XmlWriterSettings settings = new XmlWriterSettings
            {
                Encoding = Encoding.UTF8
            };

            using (XmlWriter writer = XmlWriter.Create(stream, settings))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("rss");
                writer.WriteAttributeString("version", "2.0");
                writer.WriteAttributeString("xmlns", "g", null, googleBaseNamespace);
                writer.WriteStartElement("channel");
                writer.WriteElementString("title", string.Format("{0} Google Base", SettingManager.StoreName));
                writer.WriteElementString("link", "http://base.google.com/base/");
                writer.WriteElementString("description", "Information about products");


                ProductCollection products = ProductManager.GetAllProducts(false);
                foreach (Product product in products)
                {
                    ProductVariantCollection productVariants = ProductManager.GetProductVariantsByProductID(product.ProductID, false);

                    foreach (ProductVariant productVariant in productVariants)
                    {
                        writer.WriteStartElement("item");
                        writer.WriteElementString("link", SEOHelper.GetProductURL(product));
                        writer.WriteElementString("title", productVariant.FullProductName);
                        writer.WriteStartElement("description");
                        string description = productVariant.Description;
                        if (String.IsNullOrEmpty(description))
                        {
                            description = product.FullDescription;
                        }
                        if (String.IsNullOrEmpty(description))
                        {
                            description = product.ShortDescription;
                        }
                        if (String.IsNullOrEmpty(description))
                        {
                            description = product.Name;
                        }
                        writer.WriteCData(description);
                        writer.WriteEndElement();     // description
                        writer.WriteStartElement("g", "brand", googleBaseNamespace);
                        writer.WriteFullEndElement(); // g:brand
                        writer.WriteElementString("g", "condition", googleBaseNamespace, "new");
                        writer.WriteElementString("g", "expiration_date", googleBaseNamespace, DateTime.Now.AddDays(30).ToString("yyyy-MM-dd"));
                        writer.WriteElementString("g", "id", googleBaseNamespace, productVariant.ProductVariantID.ToString());
                        string imageUrl = string.Empty;
                        ProductPictureCollection productPictures = product.ProductPictures;
                        if (productPictures.Count > 0)
                        {
                            imageUrl = PictureManager.GetPictureUrl(productPictures[0].Picture, SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize"), true);
                        }
                        writer.WriteElementString("g", "image_link", googleBaseNamespace, imageUrl);
                        decimal price = productVariant.Price;
                        writer.WriteElementString("g", "price", googleBaseNamespace, price.ToString(new CultureInfo("en-US", false).NumberFormat));
                        writer.WriteStartElement("g", "product_type", googleBaseNamespace);
                        writer.WriteFullEndElement(); // g:brand
                        //if (productVariant.Weight != decimal.Zero)
                        //{
                        //    writer.WriteElementString("g", "weight", googleBaseNamespace, string.Format(CultureInfo.InvariantCulture, "{0} {1}", productVariant.Weight.ToString(new CultureInfo("en-US", false).NumberFormat), MeasureManager.BaseWeightIn.SystemKeyword));
                        //}
                        writer.WriteEndElement(); // item
                    }
                }

                writer.WriteEndElement(); // channel
                writer.WriteEndElement(); // rss
                writer.WriteEndDocument();
            }
        }
Exemplo n.º 14
0
        private void BindData()
        {
            if (product != null)
            {
                string productURL = SEOHelper.GetProductURL(product);

                hlProduct.NavigateUrl = productURL;
                hlProduct.Text        = Server.HtmlEncode(product.Name);

                ProductPictureCollection productPictures = product.ProductPictures;
                if (productPictures.Count > 0)
                {
                    hlImageLink.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].Picture, this.ProductImageSize, true);
                    hlImageLink.ToolTip  = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name);
                    hlImageLink.Text     = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                }
                else
                {
                    hlImageLink.ImageUrl = PictureManager.GetDefaultPictureUrl(this.ProductImageSize);
                    hlImageLink.ToolTip  = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name);
                    hlImageLink.Text     = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                }

                hlImageLink.NavigateUrl = productURL;
                lShortDescription.Text  = product.ShortDescription;

                ProductVariantCollection productVariantCollection = product.ProductVariants;
                if (productVariantCollection.Count > 0)
                {
                    if (!product.HasMultipleVariants)
                    {
                        ProductVariant productVariant = productVariantCollection[0];

                        decimal oldPriceBase = TaxManager.GetPrice(productVariant, productVariant.OldPrice);
                        decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));

                        decimal oldPrice = CurrencyManager.ConvertCurrency(oldPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                        decimal finalPriceWithoutDiscount = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                        if (finalPriceWithoutDiscountBase != oldPriceBase && oldPriceBase != decimal.Zero)
                        {
                            lblOldPrice.Text = PriceHelper.FormatPrice(oldPrice);
                            lblPrice.Text    = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                        }
                        else
                        {
                            lblOldPrice.Visible = false;
                            lblPrice.Text       = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                        }

                        btnAddToCart.Visible = (!productVariant.DisableBuyButton);
                    }
                    else
                    {
                        ProductVariant productVariant = product.MinimalPriceProductVariant;
                        if (productVariant != null)
                        {
                            decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                            decimal fromPrice     = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                            lblPrice.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice));
                        }

                        btnAddToCart.Visible = false;
                    }
                }
                else
                {
                    lblOldPrice.Visible  = false;
                    lblPrice.Visible     = false;
                    btnAddToCart.Visible = false;
                }
            }
        }
Exemplo n.º 15
0
        protected void BindData()
        {
            StringBuilder allowedTokensString = new StringBuilder();

            string[] allowedTokens = Pricelist.GetListOfAllowedTokens();
            for (int i = 0; i < allowedTokens.Length; i++)
            {
                string token = allowedTokens[i];
                allowedTokensString.Append(token);
                if (i != allowedTokens.Length - 1)
                {
                    allowedTokensString.Append(", ");
                }
            }
            this.lblAllowedTokens.Text = allowedTokensString.ToString();

            Pricelist pricelist = ProductManager.GetPricelistByID(this.PricelistID);

            if (pricelist != null)
            {
                this.txtAdminNotes.Text    = pricelist.AdminNotes;
                this.txtBody.Text          = pricelist.Body;
                this.txtCacheTime.Value    = pricelist.CacheTime;
                this.txtDescription.Text   = pricelist.Description;
                this.txtDisplayName.Text   = pricelist.DisplayName;
                this.txtFooter.Text        = pricelist.Footer;
                this.txtHeader.Text        = pricelist.Header;
                this.txtPricelistGuid.Text = pricelist.PricelistGuid;
                this.txtShortName.Text     = pricelist.ShortName;
                CommonHelper.SelectListItem(this.ddlExportMode, pricelist.ExportModeID);
                CommonHelper.SelectListItem(this.ddlExportType, pricelist.ExportTypeID);
                CommonHelper.SelectListItem(this.ddlPriceAdjustmentType, pricelist.PriceAdjustmentTypeID);
                CommonHelper.SelectListItem(this.ddlAffiliate, pricelist.AffiliateID);
                this.chkOverrideIndivAdjustment.Checked  = pricelist.OverrideIndivAdjustment;
                this.txtPriceAdjustment.Value            = pricelist.PriceAdjustment;
                this.ddlFormatLocalization.SelectedValue = pricelist.FormatLocalization;

                ProductVariantCollection productVariants = new ProductVariantCollection();
                ProductCollection        products        = ProductManager.GetAllProducts();
                foreach (Product product in products)
                {
                    productVariants.AddRange(product.ProductVariants);
                }
                if (productVariants.Count > 0)
                {
                    gvProductVariants.DataSource = productVariants;
                    gvProductVariants.DataBind();
                }
            }
            else
            {
                ddlFormatLocalization.SelectedValue = System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag;

                ProductVariantCollection productVariants = new ProductVariantCollection();
                ProductCollection        products        = ProductManager.GetAllProducts();
                foreach (Product product in products)
                {
                    productVariants.AddRange(product.ProductVariants);
                }
                if (productVariants.Count > 0)
                {
                    gvProductVariants.DataSource = productVariants;
                    gvProductVariants.DataBind();
                }
            }
        }
Exemplo n.º 16
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;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Checks requirements for customer
        /// </summary>
        /// <param name="customer">Customer</param>
        /// <returns>Value indicating whether all requirements are met</returns>
        public bool CheckDiscountRequirements(Customer customer)
        {
            switch (this.DiscountRequirement)
            {
            case DiscountRequirementEnum.None:
            {
                return(true);
            }
            break;

            case DiscountRequirementEnum.MustBeAssignedToCustomerRole:
            {
                if (customer != null)
                {
                    CustomerRoleCollection customerRoles = customer.CustomerRoles;
                    CustomerRoleCollection assignedRoles = this.CustomerRoles;
                    foreach (CustomerRole _customerRole in customerRoles)
                    {
                        foreach (CustomerRole _assignedRole in assignedRoles)
                        {
                            if (_customerRole.Name == _assignedRole.Name)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            break;

            case DiscountRequirementEnum.HadPurchasedAllOfTheseProductVariants:
            {
                if (customer != null)
                {
                    ProductVariantCollection      restrictedProductVariants = ProductManager.GetProductVariantsRestrictedByDiscountId(this.DiscountId);
                    OrderProductVariantCollection purchasedProductVariants  = OrderManager.GetAllOrderProductVariants(null, customer.CustomerId, null, null, OrderStatusEnum.Complete, null, null);

                    bool allFound = true;
                    foreach (ProductVariant restrictedPV in restrictedProductVariants)
                    {
                        bool found1 = false;
                        foreach (OrderProductVariant purchasedPV in purchasedProductVariants)
                        {
                            if (restrictedPV.ProductVariantId == purchasedPV.ProductVariantId)
                            {
                                found1 = true;
                                break;
                            }
                        }

                        if (!found1)
                        {
                            allFound = false;
                            break;
                        }
                    }

                    if (allFound)
                    {
                        return(true);
                    }
                }
            }
            break;

            case DiscountRequirementEnum.HadPurchasedOneOfTheseProductVariants:
            {
                if (customer != null)
                {
                    ProductVariantCollection      restrictedProductVariants = ProductManager.GetProductVariantsRestrictedByDiscountId(this.DiscountId);
                    OrderProductVariantCollection purchasedProductVariants  = OrderManager.GetAllOrderProductVariants(null, customer.CustomerId, null, null, OrderStatusEnum.Complete, null, null);

                    bool found = false;
                    foreach (ProductVariant restrictedPV in restrictedProductVariants)
                    {
                        foreach (OrderProductVariant purchasedPV in purchasedProductVariants)
                        {
                            if (restrictedPV.ProductVariantId == purchasedPV.ProductVariantId)
                            {
                                found = true;
                                break;
                            }
                        }

                        if (found)
                        {
                            break;
                        }
                    }

                    if (found)
                    {
                        return(true);
                    }
                }
            }
            break;

            default:
                break;
            }
            return(false);
        }
Exemplo n.º 18
0
        protected void BindData()
        {
            Product product = ProductManager.GetProductByID(ProductID);
            if (product != null)
            {
                ProductVariantCollection productVariantCollection = product.ProductVariants;
                ProductVariant productVariant = null;
                if (productVariantCollection.Count > 0)
                {
                    if (!product.HasMultipleVariants)
                    {
                        productVariant = productVariantCollection[0];

                        decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));

                        lblPrice2.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscountBase);
                        if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD")
                        {
                            lblPrice1.Text = lblPrice2.Text = lblPrice2.Text + "$";
                        }
                        else
                        {
                            lblPrice1.Text = lblPrice2.Text + " руб";
                        }
                    }
                    else
                    {
                        productVariant = product.MinimalPriceProductVariant;
                        if (productVariant != null)
                        {
                            decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                            decimal fromPrice = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                            lblPrice2.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice));
                            lblPrice1.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice));
                        }
                    }
                }

                lProductName.Text = Server.HtmlEncode(product.Name);
                lShortDescription.Text = product.ShortDescription;
                lFullDescription.Text = product.FullDescription;
                imgProduct.Alt = AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);

                if (product.ProductPictures.Count > 0)
                {
                    imgProduct.Src = PictureManager.GetPictureUrl(product.ProductPictures[0].PictureID, middleImageSize);
                    a_imgProduct.HRef = DefaultHref = PictureManager.GetPictureUrl(product.ProductPictures[0].PictureID, largeImageSize);
                }
                else
                {
                    imgProduct.Src = PictureManager.GetDefaultPictureUrl(middleImageSize);
                    a_imgProduct.HRef = DefaultHref = PictureManager.GetDefaultPictureUrl(largeImageSize); ;
                }
                ProductPictureCollection productPictures = product.ProductPictures;
                if (productPictures.Count > 1)
                {
                    this.dlImages.DataSource = productPictures;
                    this.dlImages.DataBind();
                }
                else
                {
                    PanelImages.Visible = false;
                }

                lbOrder.CommandArgument = product.ProductID.ToString();
                lbOrderAndCheckout.CommandArgument = product.ProductID.ToString();
                tblOrderButtons.Visible = productVariantCollection.Count != 0 && productVariantCollection[0].StockQuantity != 0;


                StringBuilder attributes = new StringBuilder();
                foreach (ProductSpecificationAttribute psa in SpecificationAttributeManager.GetProductSpecificationAttributesByProductID(product.ProductID, false, null))
                {
                    if (psa.SpecificationAttribute.Name == "Уникальное предложение")
                        pUniqueProposal.Visible = psa.SpecificationAttributeOption.Name == "Да";
                    else
                        attributes.AppendFormat(@"<p><span class=""pink"">{0}:</span> {1}</p>", psa.SpecificationAttribute.Name, psa.SpecificationAttributeOption.Name);
                }

                lblAttributes.Text += attributes.ToString();
                if (NopContext.Current.Session == null)
                    NopContext.Current.Session = NopContext.Current.GetSession(true);
                Guid CustomerSessionGUID = NopContext.Current.Session.CustomerSessionGUID;
                ViewedItemManager.InsertViewedItem(CustomerSessionGUID, productVariant.ProductVariantID, DateTime.Now); 
            }
            else
                Visible = false;
        }
Exemplo n.º 19
0
        private static ProductVariantCollection DBMapping(DBProductVariantCollection dbCollection)
        {
            if (dbCollection == null)
                return null;

            ProductVariantCollection collection = new ProductVariantCollection();
            foreach (DBProductVariant dbItem in dbCollection)
            {
                ProductVariant item = DBMapping(dbItem);
                collection.Add(item);
            }

            return collection;
        }
Exemplo n.º 20
0
        protected void BindData()
        {
            StringBuilder allowedTokensString = new StringBuilder();
            string[] allowedTokens = Pricelist.GetListOfAllowedTokens();
            for (int i = 0; i < allowedTokens.Length; i++)
            {
                string token = allowedTokens[i];
                allowedTokensString.Append(token);
                if (i != allowedTokens.Length - 1)
                    allowedTokensString.Append(", ");
            }
            this.lblAllowedTokens.Text = allowedTokensString.ToString();

            Pricelist pricelist = ProductManager.GetPricelistByID(this.PricelistID);
            if (pricelist != null)
            {
                this.txtAdminNotes.Text = pricelist.AdminNotes;
                this.txtBody.Text = pricelist.Body;
                this.txtCacheTime.Value = pricelist.CacheTime;
                this.txtDescription.Text = pricelist.Description;
                this.txtDisplayName.Text = pricelist.DisplayName;
                this.txtFooter.Text = pricelist.Footer;
                this.txtHeader.Text = pricelist.Header;
                this.txtPricelistGuid.Text = pricelist.PricelistGuid;
                this.txtShortName.Text = pricelist.ShortName;
                CommonHelper.SelectListItem(this.ddlExportMode, pricelist.ExportModeID);
                CommonHelper.SelectListItem(this.ddlExportType, pricelist.ExportTypeID);
                CommonHelper.SelectListItem(this.ddlPriceAdjustmentType, pricelist.PriceAdjustmentTypeID);
                CommonHelper.SelectListItem(this.ddlAffiliate, pricelist.AffiliateID);
                this.chkOverrideIndivAdjustment.Checked = pricelist.OverrideIndivAdjustment;
                this.txtPriceAdjustment.Value = pricelist.PriceAdjustment;
                this.ddlFormatLocalization.SelectedValue = pricelist.FormatLocalization;

                ProductVariantCollection productVariants = new ProductVariantCollection();
                ProductCollection products = ProductManager.GetAllProducts();
                foreach (Product product in products)
                {
                    productVariants.AddRange(product.ProductVariants);
                }
                if (productVariants.Count > 0)
                {
                    gvProductVariants.DataSource = productVariants;
                    gvProductVariants.DataBind();
                }
            }
            else
            {
                ddlFormatLocalization.SelectedValue = System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag;

                ProductVariantCollection productVariants = new ProductVariantCollection();
                ProductCollection products = ProductManager.GetAllProducts();
                foreach (Product product in products)
                {
                    productVariants.AddRange(product.ProductVariants);
                }
                if (productVariants.Count > 0)
                {
                    gvProductVariants.DataSource = productVariants;
                    gvProductVariants.DataBind();
                }
            }
        }