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);
        }
예제 #2
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");
        }
예제 #3
0
        private void ProcessProductRow(ExportFeedProduts row, StreamWriter memoryBuffer)
        {
            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();

            nfi.NumberDecimalSeparator = ".";

            //Category
            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");

            //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
            //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");

            //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();
        }
예제 #5
0
        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(ShopUrl.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("\"");

            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("\"");
            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");
        }