public void CreateGoogleProductFeed(Sitecore.Data.Items.Item[] items, Sitecore.Tasks.CommandItem command,
           Sitecore.Tasks.ScheduleItem scheduleItem)
        {
            if (!GoogleProductFeedConfiguration.IsGoogleProductFeedXMLSchedulerEnabled())
            {
                Log.Info("GoogleProductFeed scheduler is disabled. To enable it check GoogleProductFeed.config-> GoogleProductFeed.SchedulerEnabled setting.", this);
                return;
            }

            if (items != null && items.Any())
            {
                Log.Info("Google Product Feed Started", this);
                foreach (var item in items)
                {
                    var sitesInConfig = GoogleProductFeedConfiguration.GetSitecoreSites();

                    var currentConfigurations = sitesInConfig.Where(x => x.RootItemPath.ToLower().Equals(item.Paths.FullPath.ToLower())).FirstOrDefault();

                    if (currentConfigurations != null)
                    {
                        try
                        {
                            List<GoogleProductFeed> feeds = new List<GoogleProductFeed>();

                            //Get Google Product Feed Configuration Item
                            Item GPFConfigurationItem = Sitecore.Configuration.Factory.GetDatabase("master").GetItem(currentConfigurations.ConfigurationPath); //Sitecore.Context.Database.GetItem(new Sitecore.Data.ID("{3DA415DD-526E-4F59-BDE4-F10D07EFC7F1}"));

                            LinkField rootFolder = GPFConfigurationItem.Fields["Root Item Path"];

                            NameValueListField GPFProperties = GPFConfigurationItem.Fields["Fields"];
                            NameValueCollection fields = GPFProperties.NameValues;

                            if (GPFProperties != null && GPFProperties.NameValues != null && GPFProperties.NameValues.Count > 0)
                            {
                                string ProductTemplateID = GPFConfigurationItem["Template"];

                                using (var context = ContentSearchManager.CreateSearchContext((SitecoreIndexableItem)item))
                                {
                                    // All Products
                                    var searchResultItems = context.GetQueryable<SearchResultItem>()
                                        .Where(x => x.TemplateId == Sitecore.Data.ID.Parse(ProductTemplateID) && x.Path.Contains(rootFolder.TargetItem.Paths.FullPath))
                                        .AsEnumerable()
                                        .Where(x => x != null && x.GetItem() != null && x.Version == x.GetItem().Versions.GetLatestVersion().Version.ToString());

                                    if (searchResultItems != null && searchResultItems.Any())
                                    {
                                        foreach (var results in searchResultItems)
                                        {
                                            GoogleProductFeed feed = new GoogleProductFeed();
                                            var itemtest = results.GetItem();
                                            feed.Title = (results.GetField(fields[FieldNames.Title]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.Title]).Value))) ? results.GetField(fields[FieldNames.Title]).Value : string.Empty;

                                            Sitecore.Links.UrlOptions URLOptions = new Sitecore.Links.UrlOptions();
                                            URLOptions.Site = Sitecore.Configuration.Factory.GetSite(currentConfigurations.SiteName);
                                            URLOptions.LanguageEmbedding = LanguageEmbedding.Never;
                                            var itemUrl = LinkManager.GetItemUrl(results.GetItem(), URLOptions);
                                            feed.Link = string.Format("{0}{1}", currentConfigurations.UrlPrefix, itemUrl);
                                            feed.Description = (results.GetField(fields[FieldNames.Description]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.Description]).Value))) ? results.GetField(fields[FieldNames.Description]).Value : string.Empty;
                                            feed.gID = (results.GetField(fields[FieldNames.gID]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gID]).Value))) ? results.GetField(fields[FieldNames.gID]).Value : string.Empty;
                                            feed.gItem_Group_ID = (results.GetField(fields[FieldNames.gItem_Group_ID]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gItem_Group_ID]).Value))) ? results.GetField(fields[FieldNames.gItem_Group_ID]).Value : string.Empty;
                                            feed.gSize = (results.GetField(fields[FieldNames.gSize]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gSize]).Value))) ? results.GetField(fields[FieldNames.gSize]).Value : string.Empty;
                                            feed.gSize_Type = (results.GetField(fields[FieldNames.gSize_Type]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gSize_Type]).Value))) ? results.GetField(fields[FieldNames.gSize_Type]).Value : string.Empty;
                                            feed.gMPN = (results.GetField(fields[FieldNames.gMPN]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gMPN]).Value))) ? results.GetField(fields[FieldNames.gMPN]).Value : string.Empty;
                                            feed.gBrand = (results.GetField(fields[FieldNames.gBrand]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gBrand]).Value))) ? results.GetField(fields[FieldNames.gBrand]).Value : string.Empty;
                                            feed.gCondition = (results.GetField(fields[FieldNames.gCondition]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gCondition]).Value))) ? results.GetField(fields[FieldNames.gCondition]).Value : string.Empty;
                                            feed.gPrice = (results.GetField(fields[FieldNames.gPrice]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gPrice]).Value))) ? results.GetField(fields[FieldNames.gPrice]).Value : string.Empty;
                                            if (!string.IsNullOrWhiteSpace(feed.gPrice) && GPFConfigurationItem.Fields["Add Currency"].Value.Equals("1"))
                                            {
                                                feed.gPrice = feed.gPrice + " " + GPFConfigurationItem.Fields["Currency"].Value;
                                            }
                                            feed.gAvailability = (results.GetField(fields[FieldNames.gAvailability]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAvailability]).Value))) ? results.GetField(fields[FieldNames.gAvailability]).Value : string.Empty;
                                            feed.gImage_Link = (results.GetField(fields[FieldNames.gImage_Link]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gImage_Link]).Value))) ? results.GetField(fields[FieldNames.gImage_Link]).Value : string.Empty;
                                            feed.gMobile_Link = (results.GetField(fields[FieldNames.gMobile_Link]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gMobile_Link]).Value))) ? results.GetField(fields[FieldNames.gMobile_Link]).Value : string.Empty;
                                            feed.gAvailability_Date = (results.GetField(fields[FieldNames.gAvailability_Date]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAvailability_Date]).Value))) ? results.GetField(fields[FieldNames.gAvailability_Date]).Value : string.Empty;
                                            feed.gSale_Price = (results.GetField(fields[FieldNames.gSale_Price]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gSale_Price]).Value))) ? results.GetField(fields[FieldNames.gSale_Price]).Value : string.Empty;
                                            feed.gTin = (results.GetField(fields[FieldNames.gTin]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gTin]).Value))) ? results.GetField(fields[FieldNames.gTin]).Value : string.Empty;
                                            feed.gColor = (results.GetField(fields[FieldNames.gColor]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gColor]).Value))) ? results.GetField(fields[FieldNames.gColor]).Value : string.Empty;
                                            feed.gGender = (results.GetField(fields[FieldNames.gGender]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gGender]).Value))) ? results.GetField(fields[FieldNames.gGender]).Value : string.Empty;
                                            feed.gAge_Group = (results.GetField(fields[FieldNames.gAge_Group]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAge_Group]).Value))) ? results.GetField(fields[FieldNames.gAge_Group]).Value : string.Empty;
                                            feed.gMaterial = (results.GetField(fields[FieldNames.gMaterial]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gMaterial]).Value))) ? results.GetField(fields[FieldNames.gMaterial]).Value : string.Empty;
                                            feed.gPattern = (results.GetField(fields[FieldNames.gPattern]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gPattern]).Value))) ? results.GetField(fields[FieldNames.gPattern]).Value : string.Empty;
                                            feed.gAdditional_Image_Link = (results.GetField(fields[FieldNames.gAdditional_Image_Link]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAdditional_Image_Link]).Value))) ? results.GetField(fields[FieldNames.gAdditional_Image_Link]).Value : string.Empty;
                                            feed.gGoogle_Product_Category = (results.GetField(fields[FieldNames.gGoogle_Product_Category]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gGoogle_Product_Category]).Value))) ? results.GetField(fields[FieldNames.gGoogle_Product_Category]).Value : string.Empty;
                                            feed.gCountry = (results.GetField(fields[FieldNames.gCountry]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gCountry]).Value))) ? results.GetField(fields[FieldNames.gCountry]).Value : string.Empty;
                                            feed.gService = (results.GetField(fields[FieldNames.gService]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gService]).Value))) ? results.GetField(fields[FieldNames.gService]).Value : string.Empty;
                                            feed.gShippingPrice = (results.GetField(fields[FieldNames.gShipping_Price]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gShipping_Price]).Value))) ? results.GetField(fields[FieldNames.gShipping_Price]).Value : string.Empty;
                                            if (!string.IsNullOrWhiteSpace(feed.gShippingPrice) && GPFConfigurationItem.Fields["Add Currency"].Value.Equals("1"))
                                            {
                                                feed.gShippingPrice = feed.gShippingPrice + " " + GPFConfigurationItem.Fields["Currency"].Value;
                                            }
                                            feed.gShipping_Weight = (results.GetField(fields[FieldNames.gShipping_Weight]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gShipping_Weight]).Value))) ? results.GetField(fields[FieldNames.gShipping_Weight]).Value : string.Empty;
                                            feed.gShipping_Label = (results.GetField(fields[FieldNames.gShipping_Label]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gShipping_Label]).Value))) ? results.GetField(fields[FieldNames.gShipping_Label]).Value : string.Empty;
                                            feed.gMultipack = (results.GetField(fields[FieldNames.gMultipack]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gMultipack]).Value))) ? results.GetField(fields[FieldNames.gMultipack]).Value : string.Empty;
                                            feed.gIs_Bundle = (results.GetField(fields[FieldNames.gIs_Bundle]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gIs_Bundle]).Value))) ? results.GetField(fields[FieldNames.gIs_Bundle]).Value : string.Empty;
                                            feed.gAdult = (results.GetField(fields[FieldNames.gAdult]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAdult]).Value))) ? results.GetField(fields[FieldNames.gAdult]).Value : string.Empty;
                                            feed.gAdwords_Redirect = (results.GetField(fields[FieldNames.gAdwords_Redirect]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAdwords_Redirect]).Value))) ? results.GetField(fields[FieldNames.gAdwords_Redirect]).Value : string.Empty;
                                            feed.gExpiration_Date = (results.GetField(fields[FieldNames.gExpiration_Date]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gExpiration_Date]).Value))) ? results.GetField(fields[FieldNames.gExpiration_Date]).Value : string.Empty;
                                            feed.gExcluded_Destination = (results.GetField(fields[FieldNames.gExcluded_Destination]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gExcluded_Destination]).Value))) ? results.GetField(fields[FieldNames.gExcluded_Destination]).Value : string.Empty;
                                            feed.gGoogle_Product_Type = new List<GoogleProductType>();
                                            GoogleProductType type = new GoogleProductType();
                                            type.gProduct_Type = (results.GetField(fields[FieldNames.gGoogle_Product_Type]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gGoogle_Product_Type]).Value))) ? results.GetField(fields[FieldNames.gGoogle_Product_Type]).Value : string.Empty;
                                            feed.gGoogle_Product_Type.Add(type);

                                            if (!string.IsNullOrWhiteSpace(feed.Description) && feed.Description.Count() > 5000)
                                            {
                                                feed.Description = feed.Description.Take(5000).ToString();
                                            }
                                            feeds.Add(feed);
                                        }
                                    }
                                }
                            }

                            try
                            {
                                if (feeds != null && feeds.Count() > 0)
                                {

                                    feeds = feeds.OrderBy(x => x.Title).ToList();
                                    string xmlContent = GoogleProductFeedCreation.BuildGoogleProductFeedXML(feeds);

                                    if (!string.IsNullOrWhiteSpace(xmlContent))
                                    {
                                        // Get Google Product Feed XML item from Master database, Update it and Publish it
                                        Database masterDb = Sitecore.Configuration.Factory.GetDatabase("master");
                                        if (masterDb != null)
                                        {
                                            Item googleProductFeedXMLItem = masterDb.GetItem(currentConfigurations.XMLPath);
                                            if (googleProductFeedXMLItem != null)
                                            {
                                                bool isItemUpdatedSuccessfully = true;
                                                GoogleProductFeedCreation.UpdateGoogleProductFeedXMLItem(googleProductFeedXMLItem, xmlContent, ref isItemUpdatedSuccessfully);

                                                if (isItemUpdatedSuccessfully)
                                                {
                                                    GoogleProductFeedCreation.PublishGoogleProductFeedXMLItem(googleProductFeedXMLItem, masterDb, true, Sitecore.Configuration.Factory.GetDatabase("web"));
                                                }
                                            }
                                            else
                                            {
                                                Log.Warn("GoogleProductFeed XML Item not found for " + Sitecore.Context.Site.StartPath, this);
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Log.Error("Error while generating googleproductfeed.xml for " + Sitecore.Context.Site, ex, this);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error in Google Product Feed", ex, this);
                        }
                    }
                }

                Log.Info("Google Product Feed Ended", this);
            }
        }
        public static XmlDocument BuildGoogleProductFeedItem(XmlDocument doc, GoogleProductFeed item)
        {
            const string prefix = "g";

            /*rss
                * channel
                    *item
                        *title
                        *link
                        *description
                        *g:id
                        *g:item_group_id
                        *g:size
                        *g:size_type
                        *g:MPN
                        *g:brand
                        *g:condition
                        *g:price
                        *g:availability
                        *g:image_link 500X500
                        *g:mobile_link
                        *g:availability_Date
                        *g:sale_Price
                        *g:tin
                        *g:color
                        *g:gender
                        *g:age_group
                        *g:material
                        *g:pattern
                        *g:additional_image_link
                        *g:google_product_category
                        *<g:shipping>
                           *<g:country>IN</g:country>
                           *<g:service>Standard</g:service>
                           *<g:price>10.00 INR</g:price>
                        *</g:shipping>
                        *g:shipping_weight
                        *g:shipping_label
                        *g:multipack
                        *g:is_bundle
                        *g:adult
                        *g:adwards_redirect
                        *g:expiration_date
                        *g:excluded_destination
                        *g:product_type
                    *item
                *channel
             *rss
             */

            XmlNode urlsetNode = doc.LastChild.LastChild;
            XmlElement itemNode = doc.CreateElement("item");
            urlsetNode.AppendChild(itemNode);

            if (!string.IsNullOrWhiteSpace(item.Title))
            {
                XmlNode titleNode = doc.CreateElement("title");
                titleNode.AppendChild(doc.CreateTextNode(item.Title));
                itemNode.AppendChild(titleNode);
            }

            if (!string.IsNullOrWhiteSpace(item.Link))
            {
                XmlNode linkNode = doc.CreateElement("link");
                linkNode.AppendChild(doc.CreateTextNode(item.Link));
                itemNode.AppendChild(linkNode);
            }

            if (!string.IsNullOrWhiteSpace(item.Description))
            {
                XmlNode descriptionNode = doc.CreateElement("description");
                descriptionNode.AppendChild(doc.CreateCDataSection(item.Description));
                itemNode.AppendChild(descriptionNode);
            }

            if (!string.IsNullOrWhiteSpace(item.gID))
            {
                XmlNode idNode = doc.CreateElement(prefix, "id", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                idNode.AppendChild(doc.CreateTextNode(item.gID));
                itemNode.AppendChild(idNode);
            }

            if (!string.IsNullOrWhiteSpace(item.gItem_Group_ID))
            {
                XmlNode itemGroupIdNode = doc.CreateElement(prefix, "item_group_id", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemGroupIdNode.AppendChild(doc.CreateTextNode(item.gItem_Group_ID));
                itemNode.AppendChild(itemGroupIdNode);
            }

            if (!string.IsNullOrWhiteSpace(item.gSize))
            {
                XmlNode sizeNode = doc.CreateElement(prefix, "size", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                sizeNode.AppendChild(doc.CreateTextNode(item.gSize));
                itemNode.AppendChild(sizeNode);
            }

            if (!string.IsNullOrWhiteSpace(item.gSize_Type))
            {
                XmlNode sizeTypeNode = doc.CreateElement(prefix, "size_type", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                sizeTypeNode.AppendChild(doc.CreateTextNode(item.gSize_Type));
                itemNode.AppendChild(sizeTypeNode);
            }

            if (!string.IsNullOrWhiteSpace(item.gMPN))
            {
                XmlNode MPNNode = doc.CreateElement(prefix, "MPN", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(MPNNode);
                MPNNode.AppendChild(doc.CreateTextNode(item.gMPN));
            }

            if (!string.IsNullOrWhiteSpace(item.gBrand))
            {
                XmlNode brandNode = doc.CreateElement(prefix, "brand", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(brandNode);
                brandNode.AppendChild(doc.CreateTextNode(item.gBrand));
            }

            if (!string.IsNullOrWhiteSpace(item.gCondition))
            {
                XmlNode conditionNode = doc.CreateElement(prefix, "condition", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(conditionNode);
                conditionNode.AppendChild(doc.CreateTextNode(item.gCondition));
            }

            if (!string.IsNullOrWhiteSpace(item.gPrice))
            {
                XmlNode priceNode = doc.CreateElement(prefix, "price", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(priceNode);
                priceNode.AppendChild(doc.CreateTextNode(item.gPrice));
            }

            if (!string.IsNullOrWhiteSpace(item.gCountry) || !string.IsNullOrWhiteSpace(item.gService) || !string.IsNullOrWhiteSpace(item.gPrice))
            {
                XmlNode shippingNode = doc.CreateElement(prefix, "shipping", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(shippingNode);

                if (!string.IsNullOrWhiteSpace(item.gCountry))
                {
                    XmlNode shippingCountryNode = doc.CreateElement(prefix, "country", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                    shippingCountryNode.AppendChild(doc.CreateTextNode(item.gCountry));
                    shippingNode.AppendChild(shippingCountryNode);
                }
                if (!string.IsNullOrWhiteSpace(item.gService))
                {
                    XmlNode shippingServiceNode = doc.CreateElement(prefix, "service", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                    shippingServiceNode.AppendChild(doc.CreateTextNode(item.gService));
                    shippingNode.AppendChild(shippingServiceNode);
                }
                if (!string.IsNullOrWhiteSpace(item.gPrice))
                {
                    XmlNode shippingPriceNode = doc.CreateElement(prefix, "price", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                    shippingPriceNode.AppendChild(doc.CreateTextNode(item.gPrice));
                    shippingNode.AppendChild(shippingPriceNode);
                }
            }

            if (!string.IsNullOrWhiteSpace(item.gAvailability))
            {
                XmlNode availabilityNode = doc.CreateElement(prefix, "availability", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(availabilityNode);
                availabilityNode.AppendChild(doc.CreateTextNode(item.gAvailability));
            }

            if (!string.IsNullOrWhiteSpace(item.gImage_Link))
            {
                XmlNode imageLinkNode = doc.CreateElement(prefix, "image_link", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(imageLinkNode);
                imageLinkNode.AppendChild(doc.CreateTextNode(item.gImage_Link));
            }

            if (!string.IsNullOrWhiteSpace(item.gMobile_Link))
            {
                XmlNode mobileLinkNode = doc.CreateElement(prefix, "mobile_link", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(mobileLinkNode);
                mobileLinkNode.AppendChild(doc.CreateTextNode(item.gMobile_Link));
            }

            if (!string.IsNullOrWhiteSpace(item.gAvailability_Date))
            {
                XmlNode availabilityDateNode = doc.CreateElement(prefix, "availability_date", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(availabilityDateNode);
                availabilityDateNode.AppendChild(doc.CreateTextNode(item.gAvailability_Date));
            }

            if (!string.IsNullOrWhiteSpace(item.gSale_Price))
            {
                XmlNode salePriceNode = doc.CreateElement(prefix, "sale_price", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(salePriceNode);
                salePriceNode.AppendChild(doc.CreateTextNode(item.gSale_Price));
            }

            if (!string.IsNullOrWhiteSpace(item.gTin))
            {
                XmlNode tinNode = doc.CreateElement(prefix, "tin", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(tinNode);
                tinNode.AppendChild(doc.CreateTextNode(item.gTin));
            }

            if (!string.IsNullOrWhiteSpace(item.gColor))
            {
                XmlNode colorNode = doc.CreateElement(prefix, "color", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(colorNode);
                colorNode.AppendChild(doc.CreateTextNode(item.gColor));
            }

            if (!string.IsNullOrWhiteSpace(item.gGender))
            {
                XmlNode genderNode = doc.CreateElement(prefix, "gender", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(genderNode);
                genderNode.AppendChild(doc.CreateTextNode(item.gGender));
            }

            if (!string.IsNullOrWhiteSpace(item.gAge_Group))
            {
                XmlNode ageGroupNode = doc.CreateElement(prefix, "age_group", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(ageGroupNode);
                ageGroupNode.AppendChild(doc.CreateTextNode(item.gAge_Group));
            }

            if (!string.IsNullOrWhiteSpace(item.gGoogle_Product_Category))
            {
                XmlNode googleProductCategoryNode = doc.CreateElement(prefix, "google_product_category", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(googleProductCategoryNode);
                googleProductCategoryNode.AppendChild(doc.CreateTextNode(item.gGoogle_Product_Category));
            }

            if (item.gGoogle_Product_Type != null && item.gGoogle_Product_Type.Count > 0)
            {
                foreach (var category in item.gGoogle_Product_Type)
                {
                    XmlNode productTypeNode = doc.CreateElement(prefix, "product_type", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                    itemNode.AppendChild(productTypeNode);
                    productTypeNode.AppendChild(doc.CreateTextNode(category.gProduct_Type));
                }
            }

            if (!string.IsNullOrWhiteSpace(item.gMaterial))
            {
                XmlNode materialNode = doc.CreateElement(prefix, "material", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(materialNode);
                materialNode.AppendChild(doc.CreateTextNode(item.gMaterial));
            }
            if (!string.IsNullOrWhiteSpace(item.gPattern))
            {
                XmlNode patternNode = doc.CreateElement(prefix, "pattern", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(patternNode);
                patternNode.AppendChild(doc.CreateTextNode(item.gPattern));
            }
            if (!string.IsNullOrWhiteSpace(item.gAdditional_Image_Link))
            {
                XmlNode additionalImageLinkNode = doc.CreateElement(prefix, "additional_image_link", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(additionalImageLinkNode);
                additionalImageLinkNode.AppendChild(doc.CreateTextNode(item.gAdditional_Image_Link));
            }
            if (!string.IsNullOrWhiteSpace(item.gShipping_Label))
            {
                XmlNode shipingLabelNode = doc.CreateElement(prefix, "shipping_label", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(shipingLabelNode);
                shipingLabelNode.AppendChild(doc.CreateTextNode(item.gShipping_Label));
            }
            if (!string.IsNullOrWhiteSpace(item.gShipping_Weight))
            {
                XmlNode shipingWeightNode = doc.CreateElement(prefix, "shipping_weight", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(shipingWeightNode);
                shipingWeightNode.AppendChild(doc.CreateTextNode(item.gShipping_Weight));
            }

            if (!string.IsNullOrWhiteSpace(item.gMultipack))
            {
                XmlNode multipackNode = doc.CreateElement(prefix, "multipack", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(multipackNode);
                multipackNode.AppendChild(doc.CreateTextNode(item.gMultipack));
            }
            if (!string.IsNullOrWhiteSpace(item.gIs_Bundle))
            {
                XmlNode isBundleNode = doc.CreateElement(prefix, "is_bundle", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(isBundleNode);
                isBundleNode.AppendChild(doc.CreateTextNode(item.gIs_Bundle));
            }
            if (!string.IsNullOrWhiteSpace(item.gAdult))
            {
                XmlNode adultNode = doc.CreateElement(prefix, "adult", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(adultNode);
                adultNode.AppendChild(doc.CreateTextNode(item.gAdult));
            }
            if (!string.IsNullOrWhiteSpace(item.gAdwords_Redirect))
            {
                XmlNode adwardsRedirectNode = doc.CreateElement(prefix, "adwards_redirect", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(adwardsRedirectNode);
                adwardsRedirectNode.AppendChild(doc.CreateTextNode(item.gAdwords_Redirect));
            }
            if (!string.IsNullOrWhiteSpace(item.gExpiration_Date))
            {
                XmlNode expiration_dateNode = doc.CreateElement(prefix, "expiration_date", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(expiration_dateNode);
                expiration_dateNode.AppendChild(doc.CreateTextNode(item.gExpiration_Date));
            }
            if (!string.IsNullOrWhiteSpace(item.gExcluded_Destination))
            {
                XmlNode excludedDestinationNode = doc.CreateElement(prefix, "excluded_destination", GoogleProductFeedConfiguration.XmlnsGoogleProductFeedValue);
                itemNode.AppendChild(excludedDestinationNode);
                excludedDestinationNode.AppendChild(doc.CreateTextNode(item.gExcluded_Destination));
            }

            return doc;
        }