public ActionResult EditPublished(ArticleViewModel articleVM, FormCollection formValues, string command)
        {
            DataAccessLayer     datalayer          = null;
            List <CategoryItem> article_categories = null;

            if (command == "Save & Preview")
            {
                if (ModelState.IsValid)
                {
                    if (Session["UserProfile"] != null)
                    {
                        List <TagItem> tags = null;

                        UserProfileItem userprofile = (UserProfileItem)Session["UserProfile"];
                        articleVM.ArticleItem.Userid = userprofile.ID;
                        string articleID = articleVM.ArticleItem.ID.ToString();
                        if (!string.IsNullOrEmpty(articleID))
                        {
                            if (!string.IsNullOrEmpty(articleVM.ArticleItem.Content))
                            {
                                articleVM.ArticleItem.Content_summary = StringHtmlExtensions.TruncateHtml(articleVM.ArticleItem.Content, CONTENT_SUMMARY_LENGTH, "....");
                            }

                            if (!string.IsNullOrEmpty(articleVM.ArticleItem.Title_English))
                            {
                                articleVM.ArticleItem.Title_SEO = articleVM.ArticleItem.Title_English.ToSeoUrl();
                            }


                            //update the article entry

                            datalayer = new DataAccessLayer();
                            if (datalayer.UpdateArticlePublished(articleVM.ArticleItem))
                            {
                                if (!string.IsNullOrEmpty(articleVM.ArticleItem.Tag_Article))
                                {
                                    //update tag table for this article
                                    tags = new List <TagItem>();
                                    var tagSplit = articleVM.ArticleItem.Tag_Article.Split(',');
                                    for (var i = 0; i < tagSplit.Length - 1; i++)
                                    {
                                        TagItem tagitem = new TagItem {
                                            id = i, name = tagSplit[i]
                                        };
                                        tags.Add(tagitem);
                                    }
                                    bool istagsupdated = datalayer.UpdateTagEntry(tags, articleVM.ArticleItem.ID);
                                    if (!istagsupdated)
                                    {
                                        //log error that tag updation failed
                                    }
                                }

                                return(RedirectToAction("ArticlePublishedOption", "Manage", new { articleid = articleID }));
                            }
                            else
                            {
                                //some error occured in updation - redirect to error page
                            }
                        }
                    }
                    else
                    {
                        return(RedirectToAction("Authenticate", "Account"));
                    }
                }
            }
            else if (command == "Cancel")
            {
                return(RedirectToAction("Index", "Manage"));
            }
            //TODO: Lot of work need to be done here for error handling, tags etc
            datalayer            = new DataAccessLayer();
            article_categories   = datalayer.GetCategories();
            articleVM.Categories = article_categories;
            StringBuilder script = new StringBuilder();

            script.Append("<script type='text/javascript'>");
            script.Append("$('#" + articleVM.ArticleItem.Category.Id + "').prop('checked', true);");
            //script.Append("$('#error_alert').show();");
            script.Append("</script>");
            ViewBag.StartScript = script.ToString();

            return(View(articleVM));
        }
        public ActionResult Edit(ArticleViewModel articleVM, FormCollection formValues, string command)
        {
            if (command == "Save & Preview")
            {
                if (ModelState.IsValid)
                {
                    if (Session["UserProfile"] != null)
                    {
                        List <TagItem> tags = null;

                        UserProfileItem userprofile = (UserProfileItem)Session["UserProfile"];
                        articleVM.ArticleItem.Userid = userprofile.ID;
                        string articleID = articleVM.ArticleItem.ID.ToString();
                        if (!string.IsNullOrEmpty(articleID))
                        {
                            if (!string.IsNullOrEmpty(articleVM.ArticleItem.Content))
                            {
                                articleVM.ArticleItem.Content_summary = StringHtmlExtensions.TruncateHtml(articleVM.ArticleItem.Content, CONTENT_SUMMARY_LENGTH, "....");
                            }

                            if (!string.IsNullOrEmpty(articleVM.ArticleItem.Title_English))
                            {
                                articleVM.ArticleItem.Title_SEO = articleVM.ArticleItem.Title_English.ToSeoUrl();
                            }


                            //update the article entry
                            DataAccessLayer datalayer = null;
                            datalayer = new DataAccessLayer();
                            if (datalayer.UpdateArticleEntry(articleVM.ArticleItem))
                            {
                                if (!string.IsNullOrEmpty(articleVM.ArticleItem.Tag_Article))
                                {
                                    //update tag table for this article
                                    tags = new List <TagItem>();
                                    var tagSplit = articleVM.ArticleItem.Tag_Article.Split(',');
                                    for (var i = 0; i < tagSplit.Length - 1; i++)
                                    {
                                        TagItem tagitem = new TagItem {
                                            id = i, name = tagSplit[i]
                                        };
                                        tags.Add(tagitem);
                                    }
                                    bool istagsupdated = datalayer.UpdateTagEntry(tags, articleVM.ArticleItem.ID);
                                    if (!istagsupdated)
                                    {
                                        //log error that tag updation failed
                                    }
                                }

                                return(RedirectToAction("ArticleOption", "Manage", new { articleid = articleID }));
                            }
                            else
                            {
                                //some error occured in updation - redirect to error page
                            }
                        }
                    }
                    else
                    {
                        return(RedirectToAction("Authenticate", "Account"));
                    }
                }
            }
            else if (command == "Cancel")
            {
                return(RedirectToAction("Index", "Manage"));
            }
            return(View(articleVM));
        }
        public ActionResult CreateArticle(ArticleViewModel articleVM, FormCollection formValues, string command)
        {
            DataAccessLayer datalayer = null;
            int             articleID = 0;
            List <TagItem>  tags      = null;

            if (command == "Save & Preview")
            {
                if (ModelState.IsValid)
                {
                    //articleVM.ID = Guid.NewGuid();
                    //articleVM.Created_Date = DateTime.Now;
                    if (Session["UserProfile"] != null)
                    {
                        UserProfileItem userprofile = (UserProfileItem)Session["UserProfile"];
                        articleVM.ArticleItem.Userid = userprofile.ID;

                        if (!string.IsNullOrEmpty(articleVM.ArticleItem.Content))
                        {
                            articleVM.ArticleItem.Content_summary = StringHtmlExtensions.TruncateHtml(articleVM.ArticleItem.Content, 200, "....");
                        }
                        if (!string.IsNullOrEmpty(articleVM.ArticleItem.Title_English))
                        {
                            articleVM.ArticleItem.Title_SEO = articleVM.ArticleItem.Title_English.ToSeoUrl();
                        }



                        //TODO: check if content is empty - return VM

                        datalayer = new DataAccessLayer();
                        articleID = datalayer.CreateArticle(articleVM.ArticleItem);
                        if (articleID != 0)
                        {
                            if (!string.IsNullOrEmpty(articleVM.ArticleItem.Tag_Article))
                            {
                                //update tag table for this article
                                tags = new List <TagItem>();
                                var tagSplit = articleVM.ArticleItem.Tag_Article.Split(',');
                                for (var i = 0; i < tagSplit.Length - 1; i++)
                                {
                                    TagItem tagitem = new TagItem {
                                        id = i, name = tagSplit[i]
                                    };
                                    tags.Add(tagitem);
                                }
                                bool istagsupdated = datalayer.UpdateTagEntry(tags, articleID);
                                if (!istagsupdated)
                                {
                                    //log error that tag updation failed
                                }
                            }

                            return(RedirectToAction("ArticleOption", "Manage", new { articleid = articleID }));
                        }
                        else
                        {
                            //some error occured while saving the article
                            return(View(articleVM));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("Authenticate", "Account"));
                    }
                }
            }
            else if (command == "Cancel")
            {
                return(RedirectToAction("Index", "Manage"));
            }

            return(View(articleVM));
        }
Beispiel #4
0
    } // End of the Create method

    /// <summary>
    /// Write one product item to the file
    /// </summary>
    /// <param name="writer">A reference to an stream writer</param>
    /// <param name="domain">A reference to a domain</param>
    /// <param name="country">A referende to a country</param>
    /// <param name="product">A reference to a product</param>
    /// <param name="currency">A reference to a currency</param>
    /// <param name="decimalMultiplier">The decimal multiplier</param>
    private static void WriteProductItem(StreamWriter writer, Domain domain, Country country, Product product, Currency currency,
        Int32 decimalMultiplier)
    {
        // Get the value added tax
        ValueAddedTax valueAddedTax = ValueAddedTax.GetOneById(product.value_added_tax_id);

        // Get the unit
        Unit unit = Unit.GetOneById(product.unit_id, domain.front_end_language);

        // Get the category
        Category category = Category.GetOneById(product.category_id, domain.front_end_language);

        // Get a chain of parent categories
        List<Category> parentCategoryChain = Category.GetParentCategoryChain(category, domain.front_end_language);

        // Create the category string
        string categoryString = "";
        for (int i = 0; i < parentCategoryChain.Count; i++)
        {
            categoryString += parentCategoryChain[i].title;

            if (i < parentCategoryChain.Count - 1)
            {
                categoryString += " > ";
            }
        }

        // Remove html from the title and the main content
        string title = StringHtmlExtensions.StripHtml(product.title);
        title = title.Replace("|", "");
        string main_content = Regex.Replace(product.main_content, @"(<br\s*[\/]>)+", " ");
        main_content = StringHtmlExtensions.StripHtml(main_content);
        main_content = Regex.Replace(main_content, @"\r\n?|\n", "");
        main_content = main_content.Replace("|", "");
        main_content = AnnytabDataValidation.TruncateString(main_content, 5000);
        
        // Calculate the price
        decimal basePrice = product.unit_price * (currency.currency_base / currency.conversion_rate);
        decimal regularPrice = Math.Round(basePrice * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;
        decimal salePrice = Math.Round(basePrice * (1 - product.discount) * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;

        // Get the country code as upper case letters
        string countryCodeUpperCase = country.country_code.ToUpper();

        // Add value added tax to the price
        if (countryCodeUpperCase != "US" && countryCodeUpperCase != "CA" && countryCodeUpperCase != "IN")
        {
            regularPrice += Math.Round(regularPrice * valueAddedTax.value * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;
            salePrice += Math.Round(salePrice * valueAddedTax.value * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;
        }

        // Calculate the freight
        decimal freight = (product.unit_freight + product.toll_freight_addition) * (currency.currency_base / currency.conversion_rate);
        freight = Math.Round(freight * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;

        // Add value added tax to the freight
        if (countryCodeUpperCase != "US" && countryCodeUpperCase != "CA" && countryCodeUpperCase != "IN")
        {
            freight += Math.Round(freight * valueAddedTax.value * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;
        }

        // Create the line to write to
        // Category|Product name|SKU|Price|Shipping Cost|Product URL|Manufacturer SKU|Manufacturer|EAN or UPC|Description|Image URL|Stock Status|Delivery time|Product state|ISBN
        string line = "";

        // Category
        line += categoryString + "|";

        // Product name
        line += title + "|";

        // SKU
        line += product.product_code + "|";

        // Price
        line += salePrice.ToString(CultureInfo.InvariantCulture) + "|";

        // Shipping Cost
        line += freight.ToString(CultureInfo.InvariantCulture) + "|";

        // Product URL
        line += domain.web_address + "/home/product/" + product.page_name + "|";

        // Manufacturer SKU
        line += product.manufacturer_code + "|";

        // Manufacturer
        line += product.brand + "|";

        // EAN or UPC
        line += product.gtin + "|";

        // Description
        line += main_content + "|";

        // Image URL
        line += domain.web_address + Tools.GetProductMainImageUrl(product.id, domain.front_end_language, product.variant_image_filename, product.use_local_images) + "|";

        // Stock Status
        line += GetAvailabilityStatus(product.availability_status) + "|";

        // Delivery time
        line += product.delivery_time + "|";

        // Product state
        line += product.condition != "" ? product.condition + "|" : "new|";

        // ISBN
        line += product.gtin;

        // Write the line to the file
        writer.WriteLine(line);

    } // End of the WriteProductItem method
Beispiel #5
0
    } // End of the Create method

    /// <summary>
    /// Write one product item to the file
    /// </summary>
    /// <param name="writer">A reference to an stream writer</param>
    /// <param name="domain">A reference to a domain</param>
    /// <param name="country">A referende to a country</param>
    /// <param name="product">A reference to a product</param>
    /// <param name="currency">A reference to a currency</param>
    /// <param name="decimalMultiplier">The decimal multiplier</param>
    private static void WriteProductItem(StreamWriter writer, Domain domain, Country country, Product product, Currency currency,
        Int32 decimalMultiplier)
    {
        // Get the unit
        Unit unit = Unit.GetOneById(product.unit_id, domain.front_end_language);

        // Get the category
        Category category = Category.GetOneById(product.category_id, domain.front_end_language);

        // Get a chain of parent categories
        List<Category> parentCategoryChain = Category.GetParentCategoryChain(category, domain.front_end_language);

        // Create the category string
        string categoryString = "";
        for (int i = 0; i < parentCategoryChain.Count; i++)
        {
            categoryString += parentCategoryChain[i].title;

            if (i < parentCategoryChain.Count - 1)
            {
                categoryString += " > ";
            }
        }

        // Remove html from the title
        string title = StringHtmlExtensions.StripHtml(product.title);
        title = title.Replace("|", " ");

        // Calculate the price
        decimal basePrice = product.unit_price * (currency.currency_base / currency.conversion_rate);
        decimal regularPrice = Math.Round(basePrice * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;
        decimal salePrice = Math.Round(basePrice * (1 - product.discount) * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;

        // Calculate the freight
        decimal freight = (product.unit_freight + product.toll_freight_addition) * (currency.currency_base / currency.conversion_rate);
        freight = Math.Round(freight * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;

        // Create the line to write to
        // product-code|product-name|manufacturer|product-url|category|price-excl-vat|shipping-excl-vat|stock-status|manufacturer-code|ean|image-url|condition
        string line = "";

        // Product code
        line += product.product_code + "|";

        // Product name
        line += title + "|";

        // Manufacturer
        line += product.brand + "|";

        // Product url
        line += domain.web_address + "/home/product/" + product.page_name + "|";

        // Category
        line += categoryString + "|";

        // Price excluding vat
        line += salePrice.ToString(CultureInfo.InvariantCulture) + "|";

        // Shipping excluding vat
        line += freight.ToString(CultureInfo.InvariantCulture) + "|";

        // Stock status
        line += GetAvailabilityStatus(product.availability_status) + "|";

        // Manufacturer code
        line += product.manufacturer_code + "|";

        // EAN
        line += product.gtin + "|";

        // Image url
        line += domain.web_address + Tools.GetProductMainImageUrl(product.id, domain.front_end_language, product.variant_image_filename, product.use_local_images) + "|";

        // Condition
        line += product.condition != "" ? product.condition : "new";

        // Write the line to the file
        writer.WriteLine(line);

    } // End of the WriteProductItem method
    } // End of the Create method

    /// <summary>
    /// Write one product item to the file
    /// </summary>
    /// <param name="writer">A reference to an xml text writer</param>
    /// <param name="domain">A reference to a domain</param>
    /// <param name="country">A referende to a country</param>
    /// <param name="product">A reference to a product</param>
    /// <param name="currency">A reference to a currency</param>
    /// <param name="decimalMultiplier">The decimal multiplier</param>
    /// <param name="googleVariants">A list with google variants</param>
    private static void WriteProductItem(XmlTextWriter writer, Domain domain, Country country, Product product, Currency currency,
                                         Int32 decimalMultiplier, List <string[]> googleVariants)
    {
        // Get the value added tax
        ValueAddedTax valueAddedTax = ValueAddedTax.GetOneById(product.value_added_tax_id);

        // Get the unit
        Unit unit = Unit.GetOneById(product.unit_id, domain.front_end_language);

        // Get the comparison unit
        Unit   comparisonUnit       = Unit.GetOneById(product.comparison_unit_id, domain.front_end_language);
        string comparison_unit_code = comparisonUnit != null ? comparisonUnit.unit_code_si : "na";

        // Get the category
        Category category = Category.GetOneById(product.category_id, domain.front_end_language);

        // Get a chain of parent categories
        List <Category> parentCategoryChain = Category.GetParentCategoryChain(category, domain.front_end_language);

        // Create the category string
        string categoryString = "";

        for (int i = 0; i < parentCategoryChain.Count; i++)
        {
            categoryString += parentCategoryChain[i].title;

            if (i < parentCategoryChain.Count - 1)
            {
                categoryString += " > ";
            }
        }

        // Write the start item tag
        writer.WriteStartElement("item");

        // Remove html from the title and the main content
        string title = StringHtmlExtensions.StripHtml(product.title);

        title = AnnytabDataValidation.TruncateString(title, 150);
        string main_content = Regex.Replace(product.main_content, @"(<br\s*[\/]>)+", " ");

        main_content = StringHtmlExtensions.StripHtml(main_content);
        main_content = Regex.Replace(main_content, @"\r\n?|\n", "");
        main_content = AnnytabDataValidation.TruncateString(main_content, 5000);

        // Write item base information
        writer.WriteStartElement("g:id");
        writer.WriteString(product.product_code);
        writer.WriteEndElement();
        writer.WriteStartElement("title");
        writer.WriteString(title);
        writer.WriteEndElement();
        writer.WriteStartElement("description");
        writer.WriteString(main_content);
        writer.WriteEndElement();
        writer.WriteStartElement("g:google_product_category");
        writer.WriteString(product.google_category);
        writer.WriteEndElement();
        writer.WriteStartElement("g:product_type");
        writer.WriteString(categoryString);
        writer.WriteEndElement();
        writer.WriteStartElement("link");
        writer.WriteString(domain.web_address + "/home/product/" + product.page_name);
        writer.WriteEndElement();
        writer.WriteStartElement("g:image_link");
        writer.WriteString(domain.web_address + Tools.GetProductMainImageUrl(product.id, domain.front_end_language, product.variant_image_filename, product.use_local_images));
        writer.WriteEndElement();
        writer.WriteStartElement("g:condition");
        writer.WriteString(product.condition != "" ? product.condition : "new");
        writer.WriteEndElement();

        // Calculate the price
        decimal basePrice    = product.unit_price * (currency.currency_base / currency.conversion_rate);
        decimal regularPrice = Math.Round(basePrice * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;
        decimal salePrice    = Math.Round(basePrice * (1 - product.discount) * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;

        // Get the country code as upper case letters
        string countryCodeUpperCase = country.country_code.ToUpper();

        // Add value added tax to the price
        if (countryCodeUpperCase != "US" && countryCodeUpperCase != "CA" && countryCodeUpperCase != "IN")
        {
            regularPrice += Math.Round(regularPrice * valueAddedTax.value * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;
            salePrice    += Math.Round(salePrice * valueAddedTax.value * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;
        }

        // Calculate the freight
        decimal freight = (product.unit_freight + product.toll_freight_addition) * (currency.currency_base / currency.conversion_rate);

        freight = Math.Round(freight * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;

        // Add value added tax to the freight
        if (countryCodeUpperCase != "US" && countryCodeUpperCase != "CA" && countryCodeUpperCase != "IN")
        {
            freight += Math.Round(freight * valueAddedTax.value * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;
        }

        // Product availability and price
        writer.WriteStartElement("g:availability");
        writer.WriteString(GetGoogleAvailabilityStatus(product.availability_status));
        writer.WriteEndElement();
        writer.WriteStartElement("g:price");
        writer.WriteString(regularPrice.ToString(CultureInfo.InvariantCulture) + " " + currency.currency_code);
        writer.WriteEndElement();

        // Set the sale price if the product has a discount
        if (product.discount > 0M)
        {
            writer.WriteStartElement("g:sale_price");
            writer.WriteString(salePrice.ToString(CultureInfo.InvariantCulture) + " " + currency.currency_code);
            writer.WriteEndElement();
        }

        // Set the availability date
        if (product.availability_status == "availability_to_order")
        {
            writer.WriteStartElement("g:availability_date");
            writer.WriteString(product.availability_date.ToString("s"));
            writer.WriteEndElement();
        }

        // Unique product codes
        writer.WriteStartElement("g:brand");
        writer.WriteString(product.brand);
        writer.WriteEndElement();
        writer.WriteStartElement("g:gtin");
        writer.WriteString(product.gtin);
        writer.WriteEndElement();
        writer.WriteStartElement("g:mpn");
        writer.WriteString(product.manufacturer_code);
        writer.WriteEndElement();

        // An indentifier does not exist if brand and mpn or gtin is missing
        if ((product.brand != "" && product.manufacturer_code != "") || product.gtin != "")
        {
            writer.WriteStartElement("g:identifier_exists");
            writer.WriteString("TRUE");
            writer.WriteEndElement();
        }
        else
        {
            writer.WriteStartElement("g:identifier_exists");
            writer.WriteString("FALSE");
            writer.WriteEndElement();
        }

        // Freight
        writer.WriteStartElement("g:shipping");
        writer.WriteStartElement("g:country");
        writer.WriteString(country.country_code);
        writer.WriteEndElement();
        writer.WriteStartElement("g:price");
        writer.WriteString(freight.ToString(CultureInfo.InvariantCulture) + " " + currency.currency_code);
        writer.WriteEndElement();
        writer.WriteEndElement();

        // Is bundle product
        if (ProductBundle.GetByBundleProductId(product.id).Count > 0)
        {
            writer.WriteStartElement("g:is_bundle");
            writer.WriteString("TRUE");
            writer.WriteEndElement();
        }

        // Gender
        if (product.gender != "")
        {
            writer.WriteStartElement("g:gender");
            writer.WriteString(product.gender);
            writer.WriteEndElement();
        }

        // Age group
        if (product.age_group != "")
        {
            writer.WriteStartElement("g:age_group");
            writer.WriteString(product.age_group);
            writer.WriteEndElement();
        }

        // Adult only
        if (product.adult_only == true)
        {
            writer.WriteStartElement("g:adult");
            writer.WriteString("TRUE");
            writer.WriteEndElement();
        }
        else
        {
            writer.WriteStartElement("g:adult");
            writer.WriteString("FALSE");
            writer.WriteEndElement();
        }

        // Unit pricing measure
        if (product.unit_pricing_measure > 0 && product.unit_pricing_base_measure > 0)
        {
            writer.WriteStartElement("g:unit_pricing_measure");
            writer.WriteString(product.unit_pricing_measure.ToString() + comparison_unit_code);
            writer.WriteEndElement();
            writer.WriteStartElement("g:unit_pricing_base_measure");
            writer.WriteString(product.unit_pricing_base_measure.ToString() + comparison_unit_code);
            writer.WriteEndElement();
        }

        // Size type
        if (product.size_type != "")
        {
            writer.WriteStartElement("g:size_type");
            writer.WriteString(GetGoogleSizeType(product.size_type));
            writer.WriteEndElement();
        }

        // Size system
        if (product.size_system != "")
        {
            writer.WriteStartElement("g:size_system");
            writer.WriteString(product.size_system);
            writer.WriteEndElement();
        }

        // Energy efficiency class
        if (product.energy_efficiency_class != "")
        {
            writer.WriteStartElement("g:energy_efficiency_class");
            writer.WriteString(product.energy_efficiency_class);
            writer.WriteEndElement();
        }

        // Add the item group id
        if (googleVariants.Count > 0)
        {
            writer.WriteStartElement("g:item_group_id");
            writer.WriteString(product.id.ToString());
            writer.WriteEndElement();
        }

        // Add google variants
        for (int i = 0; i < googleVariants.Count; i++)
        {
            // Get the value pair
            string[] valuePair = googleVariants[i];

            writer.WriteStartElement(valuePair[0]);
            writer.WriteString(valuePair[1]);
            writer.WriteEndElement();
        }

        // Write the end of the item tag
        writer.WriteEndElement();
    } // End of the WriteProductItem method