private string CreateLink(ExportFeedProduts row)
        {
            var sufix = string.Empty;

            if (!row.Main)
            {
                if (row.ColorId != 0)
                {
                    sufix = "color=" + row.ColorId;
                }
                if (row.SizeId != 0)
                {
                    if (string.IsNullOrEmpty(sufix))
                    {
                        sufix = "size=" + row.SizeId;
                    }
                    else
                    {
                        sufix += "&size=" + row.SizeId;
                    }
                }
                sufix = !string.IsNullOrEmpty(sufix) ? "?" + sufix : sufix;
            }
            return(ShopUrl.TrimEnd('/') + "/" + UrlService.GetLink(ParamType.Product, row.UrlPath, row.ProductId) + sufix);
        }
 private void ProcessProductRow(ExportFeedProduts row, XmlWriter writer)
 {
     if (string.IsNullOrWhiteSpace(row.BrandName))
     {
         ProcessSimpleModel(row, writer);
     }
     else
     {
         ProcessVendorModel(row, writer);
     }
 }
예제 #3
0
        private void ProcessProductRow(ExportFeedProduts row, XmlWriter writer)
        {
            writer.WriteStartElement("item");

            writer.WriteStartElement("title");
            writer.WriteString(row.Name);
            writer.WriteEndElement();

            writer.WriteStartElement("description");

            string desc = _description == "full" ? row.Description : row.BriefDescription;

            writer.WriteString(desc);

            writer.WriteEndElement();

            writer.WriteStartElement("link");
            writer.WriteString(SettingsGeneral.AbsoluteUrl.TrimEnd('/') + "/" + UrlService.GetLink(ParamType.Product, row.UrlPath, row.ProductID));
            writer.WriteEndElement();

            writer.WriteStartElement("g", "id");
            writer.WriteString(row.ProductID.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("g", "price");
            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();

            nfi.NumberDecimalSeparator = ".";
            writer.WriteString(CatalogService.CalculatePrice(row.Price, row.Discount).ToString(nfi));
            writer.WriteEndElement();

            writer.WriteStartElement("g", "image_link");

            var temp = row.Photo;

            if (!string.IsNullOrEmpty(temp))
            {
                writer.WriteString(GetImageProductPath(temp));
            }

            writer.WriteEndElement();

            writer.WriteStartElement("g", "currency");
            writer.WriteString(_currency);
            writer.WriteEndElement();

            writer.WriteStartElement("g", "condition");
            writer.WriteString("new");
            writer.WriteEndElement();

            writer.WriteEndElement();
        }
예제 #4
0
        private void ProcessProductRow(ExportFeedProduts row, StreamWriter memoryBuffer)
        {
            memoryBuffer.Write("\"");
            //MPN
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Manufacturer name
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //UPC
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Product Name
            memoryBuffer.Write(row.Name);
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Product Description
            string desc = _description == "full" ? row.Description : row.BriefDescription;

            memoryBuffer.Write(!string.IsNullOrEmpty(desc) ? desc : Resource.ExportFeed_NoDescription);
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Product Price
            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();

            nfi.NumberDecimalSeparator = ".";
            memoryBuffer.Write(CatalogService.CalculatePrice(row.Price, row.Discount).ToString(nfi));
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Product URL
            memoryBuffer.Write(ShopUrl.TrimEnd('/') + "/" + UrlService.GetLink(ParamType.Product, row.UrlPath, row.ProductId));
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");
            memoryBuffer.Write("\"");
            //Image URL
            if (!string.IsNullOrEmpty(row.Photos))
            {
                var temp = row.Photos.Split(',');
                var item = temp.FirstOrDefault();
                if (!string.IsNullOrEmpty(item))
                {
                    memoryBuffer.Write(GetImageProductPath(item));
                }
            }

            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Shopping.com Categorization
            var      categorizationBuffer = new StringBuilder();
            Category category             = CategoryService.GetCategory(row.ParentCategory);

            categorizationBuffer.Insert(0, category.Name);
            while (category.ParentCategoryId != 0)
            {
                category = CategoryService.GetCategory(category.ParentCategoryId);
                categorizationBuffer.Insert(0, category.Name + " >> ");
            }
            memoryBuffer.Write(categorizationBuffer.ToString());
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Stock Availability
            //memoryBuffer.Write(SQLDataHelper.GetBoolean(row["Enabled"]));
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Stock Description
            memoryBuffer.Write("shopping");
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Ground Shipping
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Weight
            //memoryBuffer.Write(SQLDataHelper.GetDecimal(row["Weight"]));
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Zip Code
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Condition
            memoryBuffer.Write("New");
            memoryBuffer.Write("\"");

            memoryBuffer.Write("\n");
        }
        private void ProcessVendorModel(ExportFeedProduts row, XmlWriter writer)
        {
            var list = new List <string>()
            {
                "a", "b"
            };

            writer.WriteStartElement("offer");
            writer.WriteAttributeString("id", row.ArtNo.XmlEncode().RemoveInvalidXmlChars());
            writer.WriteAttributeString("group_id", row.ProductId.ToString());

            writer.WriteAttributeString("available", (row.Amount > 0).ToString().ToLower());

            writer.WriteAttributeString("type", "vendor.model");

            writer.WriteStartElement("url");
            writer.WriteRaw(CreateLink(row));
            writer.WriteEndElement();

            float discount = 0;

            if (_productDiscountModels != null)
            {
                var prodDiscount = _productDiscountModels.Find(d => d.ProductId == row.ProductId);
                if (prodDiscount != null)
                {
                    discount = prodDiscount.Discount;
                }
            }

            writer.WriteStartElement("price");
            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();

            nfi.NumberDecimalSeparator = ".";
            writer.WriteRaw(Math.Round(CatalogService.CalculatePrice(row.Price, discount != 0 ? discount : row.Discount)).ToString(nfi));
            writer.WriteEndElement();

            writer.WriteStartElement("currencyId");
            writer.WriteRaw(_currency);
            writer.WriteEndElement();

            writer.WriteStartElement("categoryId");
            writer.WriteRaw(row.ParentCategory.ToString(CultureInfo.InvariantCulture));
            writer.WriteEndElement();


            if (!string.IsNullOrEmpty(row.Photos))
            {
                var temp = row.Photos.Split(',').Take(9);
                foreach (var item in temp.Where(item => !string.IsNullOrWhiteSpace(item)))
                {
                    writer.WriteStartElement("picture");
                    writer.WriteRaw(GetImageProductPath(item));
                    writer.WriteEndElement();
                }
            }

            if (_delivery)
            {
                writer.WriteStartElement("delivery");
                writer.WriteRaw(_delivery.ToString().ToLower());
                writer.WriteEndElement();
            }

            if (_localDeliveryCost)
            {
                writer.WriteStartElement("local_delivery_cost");
                writer.WriteRaw(Math.Round(row.ShippingPrice).ToString(nfi));
                writer.WriteEndElement();
            }


            writer.WriteStartElement("vendor");
            writer.WriteRaw(row.BrandName.XmlEncode().RemoveInvalidXmlChars());
            writer.WriteEndElement();

            writer.WriteStartElement("vendorCode");
            writer.WriteRaw(row.ArtNo.XmlEncode().RemoveInvalidXmlChars());
            writer.WriteEndElement();

            writer.WriteStartElement("model");
            writer.WriteRaw(row.Name.XmlEncode().RemoveInvalidXmlChars() + (!string.IsNullOrWhiteSpace(row.SizeName) ? " " + row.SizeName.XmlEncode().RemoveInvalidXmlChars() : string.Empty) + (!string.IsNullOrWhiteSpace(row.ColorName) ? " " + row.ColorName.XmlEncode().RemoveInvalidXmlChars() : string.Empty));
            writer.WriteEndElement();

            writer.WriteStartElement("description");
            string desc = SQLDataHelper.GetString(_description == "full" ? row.Description : row.BriefDescription);

            if (_removeHTML)
            {
                desc = StringHelper.RemoveHTML(desc);
            }

            writer.WriteRaw(desc.XmlEncode().RemoveInvalidXmlChars());

            writer.WriteEndElement();

            if (!string.IsNullOrWhiteSpace(row.SalesNote))
            {
                writer.WriteStartElement("sales_notes");
                writer.WriteRaw(row.SalesNote.XmlEncode().RemoveInvalidXmlChars());
                writer.WriteEndElement();
            }
            else if (!string.IsNullOrWhiteSpace(_salesNotes))
            {
                writer.WriteStartElement("sales_notes");
                writer.WriteRaw(_salesNotes.XmlEncode().RemoveInvalidXmlChars());
                writer.WriteEndElement();
            }

            if (row.ManufacturerWarranty)
            {
                writer.WriteStartElement("manufacturer_warranty");
                writer.WriteRaw(row.ManufacturerWarranty.ToString().ToLower());
                writer.WriteEndElement();
            }

            if (row.Adult)
            {
                writer.WriteStartElement("adult");
                writer.WriteRaw(row.Adult.ToString().ToLower());
                writer.WriteEndElement();
            }

            if (!string.IsNullOrWhiteSpace(row.ColorName))
            {
                writer.WriteStartElement("param");
                writer.WriteAttributeString("name", SettingsCatalog.ColorsHeader.XmlEncode().RemoveInvalidXmlChars());
                writer.WriteRaw(row.ColorName.XmlEncode().RemoveInvalidXmlChars());
                writer.WriteEndElement();
            }

            if (!string.IsNullOrWhiteSpace(row.SizeName))
            {
                writer.WriteStartElement("param");
                writer.WriteAttributeString("name", SettingsCatalog.SizesHeader.XmlEncode().RemoveInvalidXmlChars());
                writer.WriteRaw(row.SizeName.XmlEncode().RemoveInvalidXmlChars());
                writer.WriteEndElement();
            }

            if (_properties)
            {
                foreach (var prop in PropertyService.GetPropertyValuesByProductId(row.ProductId))
                {
                    if (prop.Property.Name.IsNotEmpty() && prop.Value.IsNotEmpty())
                    {
                        writer.WriteStartElement("param");
                        writer.WriteAttributeString("name", prop.Property.Name.XmlEncode().RemoveInvalidXmlChars());
                        writer.WriteRaw(prop.Value.XmlEncode().RemoveInvalidXmlChars());
                        writer.WriteEndElement();
                    }
                }
            }

            writer.WriteEndElement();
        }
예제 #6
0
        private void ProcessProductRow(ExportFeedProduts row, StreamWriter memoryBuffer)
        {
            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();
            nfi.NumberDecimalSeparator = ".";

            //Category
            var categorizationBuffer = new StringBuilder();
            var category = CategoryService.GetCategory(row.ParentCategory);
            categorizationBuffer.Insert(0, category.Name);
            while (category.ParentCategoryId != 0)
            {
                category = CategoryService.GetCategory(category.ParentCategoryId);
                categorizationBuffer.Insert(0, category.Name + " >> ");
            }
            memoryBuffer.Write(categorizationBuffer.ToString());
            memoryBuffer.Write("\t");

            //Manufacturer
            memoryBuffer.Write("\t");

            //Title
            memoryBuffer.Write(row.Name);
            memoryBuffer.Write("\t");

            //Description
            string desc = _description == "full" ? row.Description : row.BriefDescription;

            memoryBuffer.Write(!string.IsNullOrEmpty(desc) ? desc : Resource.ExportFeed_NoDescription);
            memoryBuffer.Write("\t");

            //Link
            memoryBuffer.Write(ShopUrl.TrimEnd('/') + "/" + UrlService.GetLink(ParamType.Product, row.UrlPath, row.ProductId));
            memoryBuffer.Write("\t");

            //Image
            if (!string.IsNullOrEmpty(row.Photos))
            {
                var temp = row.Photos.Split(',');
                var item = temp.FirstOrDefault();
                if (!string.IsNullOrEmpty(item))
                    memoryBuffer.Write(GetImageProductPath(item));
            }
            memoryBuffer.Write("\t");

            //SKU
            memoryBuffer.Write(row.ProductId.ToString());
            memoryBuffer.Write("\t");

            //Quantity on Hand
            memoryBuffer.Write("\t");

            //Condition
            memoryBuffer.Write("new");
            memoryBuffer.Write("\t");

            //Shipping Weight
            //memoryBuffer.Write(SQLDataHelper.GetFloat(row["Weight"]));
            memoryBuffer.Write("\t");

            //Shipping Cost
            //memoryBuffer.Write(SQLDataHelper.GetFloat(row["ShippingPrice"]).ToString(nfi));
            memoryBuffer.Write("\t");

            //Bid
            memoryBuffer.Write("\t");

            //Promo Text
            memoryBuffer.Write("\t");

            //UPC
            memoryBuffer.Write("\t");

            //Price
            memoryBuffer.Write(CatalogService.CalculatePrice(row.Price , row.Discount).ToString(nfi));
            memoryBuffer.Write("\n");
        }
예제 #7
0
        private void ProcessProductRow(ExportFeedProduts row, StreamWriter memoryBuffer)
        {
            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();

            nfi.NumberDecimalSeparator = ".";

            //Category
            var categorizationBuffer = new StringBuilder();
            var category             = CategoryService.GetCategory(row.ParentCategory);

            categorizationBuffer.Insert(0, category.Name);
            while (category.ParentCategoryId != 0)
            {
                category = CategoryService.GetCategory(category.ParentCategoryId);
                categorizationBuffer.Insert(0, category.Name + " >> ");
            }
            memoryBuffer.Write(categorizationBuffer.ToString());
            memoryBuffer.Write("\t");

            //Manufacturer
            memoryBuffer.Write("\t");

            //Title
            memoryBuffer.Write(row.Name);
            memoryBuffer.Write("\t");

            //Description
            string desc = _description == "full" ? row.Description : row.BriefDescription;

            memoryBuffer.Write(!string.IsNullOrEmpty(desc) ? desc : Resource.ExportFeed_NoDescription);
            memoryBuffer.Write("\t");

            //Link
            memoryBuffer.Write(SettingsGeneral.AbsoluteUrl.TrimEnd('/') + "/" + UrlService.GetLink(ParamType.Product, row.UrlPath, row.ProductID));
            memoryBuffer.Write("\t");

            //Image
            var temp = row.Photo;

            if (!string.IsNullOrEmpty(temp))
            {
                memoryBuffer.Write(GetImageProductPath(row.Photo));
            }
            memoryBuffer.Write("\t");

            //SKU
            memoryBuffer.Write(row.ProductID.ToString());
            memoryBuffer.Write("\t");

            //Quantity on Hand
            memoryBuffer.Write("\t");

            //Condition
            memoryBuffer.Write("new");
            memoryBuffer.Write("\t");

            //Shipping Weight
            //memoryBuffer.Write(SQLDataHelper.GetDecimal(row["Weight"]));
            memoryBuffer.Write("\t");

            //Shipping Cost
            //memoryBuffer.Write(SQLDataHelper.GetDecimal(row["ShippingPrice"]).ToString(nfi));
            memoryBuffer.Write("\t");

            //Bid
            memoryBuffer.Write("\t");

            //Promo Text
            memoryBuffer.Write("\t");

            //UPC
            memoryBuffer.Write("\t");

            //Price
            memoryBuffer.Write(CatalogService.CalculatePrice(row.Price, row.Discount).ToString(nfi));
            memoryBuffer.Write("\n");
        }
        private void ProcessProductRow(ExportFeedProduts row, XmlWriter writer)
        {
            writer.WriteStartElement("item");

            #region ќсновные сведени¤ о товарах

            //id
            writer.WriteElementString("g", "id", GoogleBaseNamespace, row.OfferId.ToString(CultureInfo.InvariantCulture));

            //title [title]
            writer.WriteStartElement("title");
            var title = row.Name.XmlEncode().RemoveInvalidXmlChars();
            //title should be not longer than 70 characters
            if (title.Length > 70)
            {
                title = title.Substring(0, 70);
            }
            writer.WriteCData(title);
            writer.WriteEndElement();

            //description

            var desc = _description == "full" ? row.Description : row.BriefDescription;
            if (_removeHTML)
            {
                desc = StringHelper.RemoveHTML(desc);
            }

            if (desc.IsNotEmpty())
            {
                writer.WriteStartElement("description");
                writer.WriteCData(desc.XmlEncode().RemoveInvalidXmlChars());
                writer.WriteEndElement();
            }

            //google_product_category http://www.google.com/support/merchants/bin/answer.py?answer=160081
            var googleProductCategory = row.GoogleProductCategory;
            if (string.IsNullOrEmpty(googleProductCategory))
            {
                googleProductCategory = _googleProductCategory;
            }
            writer.WriteStartElement("g", "google_product_category", GoogleBaseNamespace);
            writer.WriteCData(googleProductCategory.XmlEncode().RemoveInvalidXmlChars());
            writer.WriteEndElement();

            //product_type
            var localPath = string.Empty;
            var cats      = CategoryService.GetParentCategories(row.ParentCategory).Reverse()
                            .Select(cat => new
            {
                Name = cat.Name,
                Url  = UrlService.GetLink(ParamType.Category, cat.UrlPath, cat.ID)
            }).ToList();
            for (var i = 0; i < cats.Count; i++)
            {
                var cat = cats[i];
                localPath = localPath + cat.Name;
                if (i == cats.Count - 1)
                {
                    continue;
                }
                localPath = localPath + " > ";
            }
            writer.WriteStartElement("g", "product_type", GoogleBaseNamespace);
            writer.WriteCData(localPath.XmlEncode().RemoveInvalidXmlChars());
            writer.WriteEndElement();

            if (row.Adult)
            {
                writer.WriteElementString("g", "adult", GoogleBaseNamespace, row.Adult.ToString());
            }


            //link
            writer.WriteElementString("link", ShopUrl.TrimEnd('/') + "/" + UrlService.GetLink(ParamType.Product, row.UrlPath, row.ProductId));

            //image link
            if (!string.IsNullOrEmpty(row.Photos))
            {
                var temp = row.Photos.Split(',');
                for (var i = 0; i < temp.Length; i++)
                {
                    writer.WriteElementString("g", i == 0 ? "image_link" : "additional_image_link", GoogleBaseNamespace, GetImageProductPath(temp[i]));
                }
            }

            //condition
            writer.WriteElementString("g", "condition", GoogleBaseNamespace, "new");
            #endregion


            #region наличие и цена
            //availability
            const string availability = "in stock";
            writer.WriteElementString("g", "availability", GoogleBaseNamespace, availability);


            float discount = 0;
            if (_productDiscountModels != null)
            {
                var prodDiscount = _productDiscountModels.Find(d => d.ProductId == row.ProductId);
                if (prodDiscount != null)
                {
                    discount = prodDiscount.Discount;
                }
            }

            writer.WriteElementString("g", "price", GoogleBaseNamespace, Math.Round(CatalogService.CalculatePrice(row.Price, discount != 0 ? discount : row.Discount)).ToString());

            #endregion

            #region ”никальные идентификаторы товаров
            //GTIN
            var gtin = row.Gtin;
            if (!string.IsNullOrEmpty(gtin))
            {
                writer.WriteStartElement("g", "gtin", GoogleBaseNamespace);
                writer.WriteCData(gtin);
                writer.WriteFullEndElement(); // g:gtin
            }

            //brand
            if (!string.IsNullOrEmpty(row.BrandName))
            {
                writer.WriteStartElement("g", "brand", GoogleBaseNamespace);
                writer.WriteCData(row.BrandName.XmlEncode().RemoveInvalidXmlChars());
                writer.WriteFullEndElement(); // g:brand
            }

            //mpn [mpn]
            if (!string.IsNullOrEmpty(row.ArtNo))
            {
                writer.WriteStartElement("g", "mpn", GoogleBaseNamespace);
                writer.WriteCData(row.ArtNo.XmlEncode().RemoveInvalidXmlChars());
                writer.WriteFullEndElement(); // g:mpn
            }
            #endregion

            #region ¬арианты товара
            if (!(row.ColorName.IsNullOrEmpty() || row.SizeName.IsNullOrEmpty()))
            {
                //item_group_id
                writer.WriteElementString("g", "item_group_id", GoogleBaseNamespace, row.ProductId.ToString());
                //color
                writer.WriteElementString("g", "color", GoogleBaseNamespace, row.ColorName.XmlEncode().RemoveInvalidXmlChars());
                //color
                writer.WriteElementString("g", "size", GoogleBaseNamespace, row.SizeName.XmlEncode().RemoveInvalidXmlChars());
            }

            #endregion

            #region Tax & Shipping
            #endregion

            writer.WriteElementString("g", "expiration_date", GoogleBaseNamespace, DateTime.Now.AddDays(28).ToString("yyyy-MM-dd"));
            writer.WriteEndElement();
        }
예제 #9
0
        private void ProcessVendorModel(ExportFeedProduts row, XmlWriter writer)
        {
            writer.WriteStartElement("offer");
            writer.WriteAttributeString("id", row.OfferId.ToString(CultureInfo.InvariantCulture));
            writer.WriteAttributeString("available", (row.Amount > 0).ToString().ToLower());

            writer.WriteAttributeString("type", "vendor.model");

            writer.WriteStartElement("url");
            writer.WriteString(CreateLink(row));
            writer.WriteEndElement();

            writer.WriteStartElement("price");
            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();
            nfi.NumberDecimalSeparator = ".";
            writer.WriteString(Math.Round(CatalogService.CalculatePrice(row.Price, row.Discount)).ToString(nfi));
            writer.WriteEndElement();

            writer.WriteStartElement("currencyId");
            writer.WriteString(_currency == "RUB" ? "RUR" : _currency);
            writer.WriteEndElement();

            writer.WriteStartElement("categoryId");
            writer.WriteString(row.ParentCategory.ToString(CultureInfo.InvariantCulture));
            writer.WriteEndElement();

            if (!string.IsNullOrEmpty(row.Photos))
            {
                var temp = row.Photos.Split(',');
                foreach (var item in temp.Where(item => !string.IsNullOrWhiteSpace(item)))
                {
                    writer.WriteStartElement("picture");
                    writer.WriteString(GetImageProductPath(item));
                    writer.WriteEndElement();
                }
            }

            writer.WriteStartElement("delivery");
            writer.WriteString(_delivery.ToString().ToLower());
            writer.WriteEndElement();

            writer.WriteStartElement("vendor");
            writer.WriteString(row.BrandName);
            writer.WriteEndElement();

            writer.WriteStartElement("vendorCode");
            writer.WriteString(row.ArtNo);
            writer.WriteEndElement();

            writer.WriteStartElement("model");
            writer.WriteString(row.Name + (!string.IsNullOrWhiteSpace(row.SizeName) ? " " + row.SizeName : string.Empty) + (!string.IsNullOrWhiteSpace(row.ColorName) ? " " + row.ColorName : string.Empty));
            writer.WriteEndElement();

            writer.WriteStartElement("description");
            string desc = SQLDataHelper.GetString(_description == "full" ? row.Description : row.BriefDescription);

            writer.WriteString(desc.XmlEncode().RemoveInvalidXmlChars());

            writer.WriteEndElement();

            if (!string.IsNullOrWhiteSpace(row.SalesNote))
            {
                writer.WriteStartElement("sales_notes");
                writer.WriteString(row.SalesNote);
                writer.WriteEndElement();
            }
            else if (!string.IsNullOrWhiteSpace(_salesNotes))
            {
                writer.WriteStartElement("sales_notes");
                writer.WriteString(_salesNotes);
                writer.WriteEndElement();
            }

            if (!string.IsNullOrWhiteSpace(row.ColorName))
            {
                writer.WriteStartElement("param");
                writer.WriteAttributeString("name", "Цвет");
                writer.WriteString(row.ColorName);
                writer.WriteEndElement();
            }

            if (!string.IsNullOrWhiteSpace(row.SizeName))
            {
                writer.WriteStartElement("param");
                writer.WriteAttributeString("name", "Размер");
                writer.WriteString(row.SizeName);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
        }
예제 #10
0
        private void ProcessProductRow(ExportFeedProduts row, XmlWriter writer)
        {
            //var tempUrl = (_shopUrl.EndsWith("/") ? _shopUrl.TrimEnd('/') : _shopUrl);
            writer.WriteStartElement("offer");
            writer.WriteAttributeString("id", row.ProductID.ToString());
            writer.WriteAttributeString("available", (row.Amount > 0).ToString().ToLower());

            writer.WriteStartElement("url");
            writer.WriteString(SettingsGeneral.AbsoluteUrl.TrimEnd('/') + "/" + UrlService.GetLink(ParamType.Product, row.UrlPath, row.ProductID));
            writer.WriteEndElement();


            writer.WriteStartElement("price");
            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();

            nfi.NumberDecimalSeparator = ".";
            writer.WriteString(CatalogService.CalculatePrice(row.Price, row.Discount).ToString(nfi));
            writer.WriteEndElement();

            writer.WriteStartElement("currencyId");
            writer.WriteString(_currency == "RUB" ? "RUR" : _currency);
            writer.WriteEndElement();

            writer.WriteStartElement("categoryId");
            writer.WriteString(row.ParentCategory.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("picture");
            var photo = SQLDataHelper.GetString(row.Photo);

            if (!string.IsNullOrEmpty(photo))
            {
                writer.WriteString(GetImageProductPath(photo));
            }
            writer.WriteEndElement();

            writer.WriteStartElement("name");

            //Added by Evgeni to Change product Name like in Description
            //from details.aspx

            if (!row.Name.ToLower().Contains(row.BrandName.ToLower()))
            {
                if (row.BrandName.ToLower() == "bosch" && Regex.IsMatch(row.Name, @"[A-Z]"))
                {
                    row.Name = row.Name.Insert(Regex.Match(row.Name, @"[A-Z]").Index, row.BrandName + ' ');
                }
                else
                {
                    row.Name = row.BrandName + " " + row.Name;
                }
            }
            if (!row.Name.ToLower().Contains(row.ArtNo.Replace(".", "").Replace("-", "").ToLower()))
            {
                row.Name = row.Name + " [" + row.ArtNo.Replace(".", "").Replace("-", "") + "]";
            }

            ///

            writer.WriteString(row.Name);
            writer.WriteEndElement();

            writer.WriteStartElement("description");
            string desc = SQLDataHelper.GetString(_description == "full" ? row.Description : row.BriefDescription);

            writer.WriteString(desc);

            writer.WriteEndElement();

            if (_salesNotes.IsNotEmpty())
            {
                writer.WriteStartElement("sales_notes");
                writer.WriteString(_salesNotes);
                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
예제 #11
0
 private void ProcessProductRow(ExportFeedProduts row, XmlWriter writer)
 {
     if (string.IsNullOrWhiteSpace(row.BrandName)) ProcessSimpleModel(row, writer);
     else ProcessVendorModel(row, writer);
 }
예제 #12
0
 private string CreateLink(ExportFeedProduts row)
 {
     var sufix = string.Empty;
     if (!row.Main)
     {
         if (row.ColorId != 0)
             sufix = "color=" + row.ColorId;
         if (row.SizeId != 0)
         {
             if (string.IsNullOrEmpty(sufix))
                 sufix = "size=" + row.SizeId;
             else
                 sufix += "&size=" + row.SizeId;
         }
         sufix = !string.IsNullOrEmpty(sufix) ? "?" + sufix : sufix;
     }
     return ShopUrl.TrimEnd('/') + "/" + UrlService.GetLink(ParamType.Product, row.UrlPath, row.ProductId) + sufix;
 }
        private void ProcessProductRow(ExportFeedProduts row, XmlWriter writer)
        {
            writer.WriteStartElement("item");

            writer.WriteStartElement("title");
            writer.WriteString(row.Name);
            writer.WriteEndElement();

            writer.WriteStartElement("description");

            string desc = _description == "full" ? row.Description : row.BriefDescription;
            writer.WriteString(desc);

            writer.WriteEndElement();

            writer.WriteStartElement("link");
            writer.WriteString(ShopUrl.TrimEnd('/') + "/" + UrlService.GetLink(ParamType.Product, row.UrlPath, row.ProductId));
            writer.WriteEndElement();

            writer.WriteStartElement("g", "id");
            writer.WriteString(row.ProductId.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("g", "price");
            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();
            nfi.NumberDecimalSeparator = ".";
            writer.WriteString(CatalogService.CalculatePrice(row.Price, row.Discount).ToString(nfi));
            writer.WriteEndElement();

            writer.WriteStartElement("g", "image_link");

            if (!string.IsNullOrEmpty(row.Photos))
            {
                var temp = row.Photos.Split(',');
                var item = temp.FirstOrDefault();
                if (!string.IsNullOrEmpty(item))
                    writer.WriteString(GetImageProductPath(item));
            }

            writer.WriteEndElement();

            writer.WriteStartElement("g", "currency");
            writer.WriteString(_currency);
            writer.WriteEndElement();

            writer.WriteStartElement("g", "condition");
            writer.WriteString("new");
            writer.WriteEndElement();

            writer.WriteEndElement();
        }
        private void ProcessDataRow(ExportFeedProduts row, StreamWriter memoryBuffer)
        {
            var tempId = row.ProductID;

            memoryBuffer.Write("\"");
            memoryBuffer.Write(tempId);
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            memoryBuffer.Write("");
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            memoryBuffer.Write(row.Name);
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            var      categorizationBuffer = new StringBuilder();
            Category category             = CategoryService.GetCategory(row.ParentCategory);

            categorizationBuffer.Insert(0, category.Name);
            while (category.ParentCategoryId != 0)
            {
                category = CategoryService.GetCategory(category.ParentCategoryId);
                categorizationBuffer.Insert(0, category.Name + " >> ");
            }
            memoryBuffer.Write(categorizationBuffer.ToString());
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            memoryBuffer.Write(SettingsGeneral.AbsoluteUrl.TrimEnd('/') + "/" + UrlService.GetLink(ParamType.Product, row.UrlPath, row.ProductID));
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            //memoryBuffer.Write("\"");
            //memoryBuffer.Write(GetShopUrl() + GetProductLink(tempId));
            //memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            var temp = row.Photo;

            if (!string.IsNullOrEmpty(temp))
            {
                memoryBuffer.Write(GetImageProductPath(temp));
            }
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            string desc = _descriptionSelecton == "full" ? row.Description : row.BriefDescription;

            memoryBuffer.Write(!string.IsNullOrEmpty(desc) ? desc : Resource.ExportFeed_NoDescription);
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();

            nfi.NumberDecimalSeparator = ".";
            memoryBuffer.Write(CatalogService.CalculatePrice(row.Price, row.Discount).ToString(nfi));
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            memoryBuffer.Write("New");
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            //memoryBuffer.Write("\"");
            //memoryBuffer.Write(row["Enabled"]);
            //memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            //memoryBuffer.Write("\"");
            //memoryBuffer.Write(SQLDataHelper.GetDecimal(row["ShippingPrice"]).ToString(nfi));
            //memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            //memoryBuffer.Write("\"");
            //memoryBuffer.Write(SQLDataHelper.GetDecimal(row["Weight"]));
            //memoryBuffer.Write("\"");

            memoryBuffer.Write("\n");
        }
        private void ProcessProductRow(ExportFeedProduts row, StreamWriter memoryBuffer)
        {
            memoryBuffer.Write(row.ProductId.ToString());
            memoryBuffer.Write("\t");

            memoryBuffer.Write(row.Name);
            memoryBuffer.Write("\t");

            string desc = _description == "full" ? row.Description : row.BriefDescription;

            memoryBuffer.Write(!string.IsNullOrEmpty(desc) ? desc : Resource.ExportFeed_NoDescription);
            memoryBuffer.Write("\t");

            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();
            nfi.NumberDecimalSeparator = ".";
            memoryBuffer.Write(CatalogService.CalculatePrice(row.Price, row.Discount).ToString(nfi));
            memoryBuffer.Write("\t");

            memoryBuffer.Write(ShopUrl.TrimEnd('/') + "/" + UrlService.GetLink(ParamType.Product, row.UrlPath, row.ProductId));
            memoryBuffer.Write("\t");

            var categorizationBuffer = new StringBuilder();
            Category category = CategoryService.GetCategory(row.ParentCategory);
            categorizationBuffer.Insert(0, category.Name);
            while (category.ParentCategoryId != 0)
            {
                category = CategoryService.GetCategory(category.ParentCategoryId);
                categorizationBuffer.Insert(0, category.Name + " >> ");
            }
            memoryBuffer.Write(categorizationBuffer.ToString());
            memoryBuffer.Write("\t");

            memoryBuffer.Write("None");
            memoryBuffer.Write("\t");
            //Image URL
            if (!string.IsNullOrEmpty(row.Photos))
            {
                var temp = row.Photos.Split(',');
                var item = temp.FirstOrDefault();
                if (!string.IsNullOrEmpty(item))
                    memoryBuffer.Write(GetImageProductPath(item));
            }
            memoryBuffer.Write("\t");

            memoryBuffer.Write("\t");

            memoryBuffer.Write("\t");

            memoryBuffer.Write("\t");

            memoryBuffer.Write(row.Price.ToString(nfi));
            memoryBuffer.Write("\t");

            //memoryBuffer.Write(SQLDataHelper.GetBoolean(row["Enabled"]));
            //memoryBuffer.Write("\t");

            //memoryBuffer.Write(SQLDataHelper.GetDecimal(row["ShippingPrice"]).ToString(nfi));
            //memoryBuffer.Write("\t");

            //memoryBuffer.Write(SQLDataHelper.GetDecimal(row["Weight"]));
            //memoryBuffer.Write("\n");
        }