public ItemQuery Get(string queryName) { var rootId = SettingsHelper.GetQueriesRootId(); var itemQueriesRootId = Db.GetItem(rootId); if (itemQueriesRootId == null) { return(null); } var item = itemQueriesRootId.Children.SingleOrDefault( n => n["Name"].Equals(queryName, StringComparison.OrdinalIgnoreCase)); if (item == null) { throw new Exception( string.Format( "The item query '{0}' could not be found.", queryName, rootId)); } var defaultParamsField = new NameValueListField(item.Fields["Default Params"]); var itemQuery = new ItemQuery { Name = item["Name"], Query = item["Query"], DefaultParams = defaultParamsField.NameValues }; return(itemQuery); }
public void CloneOrRemoveItemsInMalls(Item sourceItem) { if (!sourceItem.IsDerived(Templates.MallSite.ID)) { throw new TemplateNotFoundException(); } var mainSite = sourceItem.GetSiteItem(); MultilistField mallSiteSetting = mainSite.Fields[Templates.MainSiteSetting.Fields.MallSites]; if (mallSiteSetting.Value.IsNullOrEmpty()) { throw new ClientAlertException("Mall Site Setting is not correct"); } MultilistField mallSiteInput = sourceItem.Fields[Templates.MallSite.Fields.SiteDisplaySettings]; NameValueListField targetIds = sourceItem.Fields[HiddenFields.Templates.HiddenField.Fields.TargetIds]; var setting = new MultisiteSettingCollection(targetIds.NameValues, mallSiteSetting.GetItems(), mallSiteInput.GetItems()); var targetIdsResult = targetIds.NameValues; foreach (var site in setting.CloneSites) { this.CloneItem(sourceItem, site, targetIdsResult); } foreach (var removeItem in setting.RemoveItemIds) { var item = sourceItem.Database.GetItem(removeItem.DeleteItemId); item.Delete(); targetIdsResult.Remove(removeItem.SiteId.ToShortID().ToString()); } targetIds.NameValues = targetIdsResult; }
private void DeleteItemOnMallSite(Item deletingItem) { var id = deletingItem.Fields[HiddenFields.Templates.HiddenField.Fields.SourceId].Value; if (id.IsNullOrEmpty()) { return; } var referenceItem = deletingItem.Database.GetItem(new ID(id)); if (referenceItem != null && referenceItem.IsBelongToMainSite()) { using (new Sitecore.SecurityModel.SecurityDisabler()) { referenceItem.Editing.BeginEdit(); try { var mallSiteId = deletingItem.GetSiteItem().ID; NameValueListField targetIds = referenceItem.Fields[HiddenFields.Templates.HiddenField.Fields.TargetIds]; var tagets = targetIds.NameValues; tagets.Remove(mallSiteId.ToShortID().ToString()); targetIds.NameValues = tagets; ((MultilistField)referenceItem.Fields[Templates.MallSite.Fields.SiteDisplaySettings]).Remove(mallSiteId.ToString()); } catch (Exception ex) { Log.Error($"Could not set source ID | {ex.Message}", nameof(DeleteItemEventHandle)); referenceItem.Editing.CancelEdit(); } referenceItem.Editing.EndEdit(); } } }
public override void Initialize(Sitecore.Mvc.Presentation.Rendering rendering) { base.Initialize(rendering); try { item = Item.Database.GetItem(Rendering.DataSource); isDatasourceNull = item == null ? true : false; if (!isDatasourceNull) { NameValueListField deptList = item.Fields["Default URL"]; if (deptList != null) { System.Collections.Specialized.NameValueCollection nameValueCollection = deptList.NameValues; foreach (string deptName in nameValueCollection.AllKeys) { if (User.Current.IsInRole("hscnet\\SC_" + deptName + "_CONTENT")) { targetLocation = nameValueCollection[deptName]; break; } } } } } catch { isDatasourceNull = true; } }
private void CopyItemFromMainToMall(Item savingItem) { var sourceId = (ReferenceField)savingItem.Fields[HiddenFields.Templates.HiddenField.Fields.SourceId]; MultilistField mallSitesInput = savingItem.Fields[Templates.MallSite.Fields.SiteDisplaySettings]; NameValueListField targetIds = savingItem.Fields[HiddenFields.Templates.HiddenField.Fields.TargetIds]; if (mallSitesInput.Value.IsNullOrEmpty() && targetIds.Value.IsNullOrEmpty()) { return; // mall sites is not input } if (!string.IsNullOrEmpty(sourceId.Value)) { return; // Item come from mall site } this.mainSiteWorkflow.CloneOrRemoveItemsInMalls(savingItem); }
public void ChangeStateItemsInMalls(Item sourceItem, ID state) { if (!sourceItem.IsDerived(Templates.MallSite.ID)) { throw new TemplateNotFoundException(); } NameValueListField targetIds = sourceItem.Fields[HiddenFields.Templates.HiddenField.Fields.TargetIds]; if (targetIds == null) { return; } foreach (string key in targetIds.NameValues) { var item = sourceItem.Database.GetItem(new ID(targetIds.NameValues[key])); this.stateRepository.ChangeItemStateTo(item, state); } }
private Item GetCopiedItemFromMallToMain(Item currentItem) { var sourceId = (ReferenceField)currentItem.Fields[HiddenFields.Templates.HiddenField.Fields.SourceId]; if (!string.IsNullOrEmpty(sourceId.Value)) { return(null); // Item come from main site } NameValueListField targetIds = currentItem.Fields[HiddenFields.Templates.HiddenField.Fields.TargetIds]; if (targetIds.Value.IsNullOrEmpty()) { return(null); // Item is sent to main site } var copiedItem = this.mallSiteWorkflowRepository.GetCopiedItemInMainSite(currentItem); return(copiedItem); }
protected virtual Dictionary <string, object> GetAdditionalParameters(MediaGenerateMarkupArgs args) { var parameters = new Dictionary <string, object> { { "onCreate", new JRaw("ooyalaListener.subscribeEvents") } }; NameValueListField field = args.PlayerItem.Fields[FieldIDs.Player.Parameters]; if (field != null) { var collection = field.NameValues; foreach (string key in collection) { string value = HttpUtility.UrlDecode(collection[key]); parameters[key] = new JRaw(value); } } return(parameters); }
public ActionResult FacultyDirectoryCorporate(string itemId, string key, string value, string type, string movementTo) { FacultyDirectoryCorporate facultyList = new FacultyDirectoryCorporate(); facultyList.rendering = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull.Rendering; facultyList.item = facultyList.rendering.Item; facultyList.pageItem = PageContext.Current.Item; facultyList.isDatasourceNull = true; facultyList.allFacultyData = ""; try { Item item = facultyList.item.Database.GetItem(facultyList.rendering.DataSource); facultyList.pageItem = PageContext.Current.Item; facultyList.isDatasourceNull = (item != null ? false : true); if (facultyList.isDatasourceNull) { throw new ArgumentNullException("args.Item"); } else { } } catch { facultyList.isDatasourceNull = true; } // If page is xEditor if (Sitecore.Context.PageMode.IsExperienceEditor) { // Create new branch if (!String.IsNullOrEmpty(itemId) && type == "Add New Branch" && !String.IsNullOrEmpty(key)) { Item parent = facultyList.item.Database.GetItem(Sitecore.Data.ID.Parse(itemId)); string templatePath = "/sitecore/templates/Branches/Faculty Directory Corporate/Faculty Directory DB Section"; if (key == "DB Section") { templatePath = "/sitecore/templates/Branches/Faculty Directory Corporate/Faculty Directory DB Section"; } else if (key == "Input Section") { templatePath = "/sitecore/templates/Branches/Faculty Directory Corporate/Faculty Directory Input Section"; } string itemName = parent.HasChildren ? facultyList.pageItem.Name + "_Section" + parent.Children.Count().ToString() : facultyList.pageItem.Name + "_Section"; BranchItem branch = facultyList.item.Database.GetItem(templatePath); parent.Add(itemName, branch); } // Add new faculty into the list if (!String.IsNullOrEmpty(key) && type == "Add New Faculty") { Item item = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(itemId.Trim())); if (key == "User Input") { Item parent = facultyList.item.Database.GetItem(Sitecore.Data.ID.Parse(itemId)); string itemName = parent.HasChildren ? parent.Name + "_Input_View" + parent.Children.Count().ToString() : parent.Name + "_Input_View"; TemplateItem template = facultyList.item.Database.GetTemplate("User Defined2/Component Template/Faculty Directory Corporate/Faculty Directory Input View"); parent.Add(itemName, template); } else { NameValueListField data = item.Fields["Faculty List"]; System.Collections.Specialized.NameValueCollection nameValueCollection = data.NameValues; using (new Sitecore.SecurityModel.SecurityDisabler()) { item.Editing.BeginEdit(); if (String.IsNullOrEmpty(item.Fields["Faculty List"].Value)) { item.Fields["Faculty List"].Value = key + "=;dump;"; } else { item.Fields["Faculty List"].Value = item.Fields["Faculty List"].Value + "&" + key + "=;dump;"; } item.Editing.EndEdit(); item.Editing.AcceptChanges(); Sitecore.Data.Managers.ItemManager.SaveItem(item); } } } // Remove faculty in the list if (!String.IsNullOrEmpty(key) && type == "Remove Faculty") { Item item = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(itemId.Trim())); NameValueListField data = item.Fields["Faculty List"]; System.Collections.Specialized.NameValueCollection nameValueCollection = data.NameValues; using (new Sitecore.SecurityModel.SecurityDisabler()) { item.Editing.BeginEdit(); nameValueCollection.Remove(key); data.NameValues = nameValueCollection; item.Editing.EndEdit(); item.Editing.AcceptChanges(); Sitecore.Data.Managers.ItemManager.SaveItem(item); } } // Sort Faculty List if (!String.IsNullOrEmpty(key) && !String.IsNullOrEmpty(movementTo) && type == "Sort Faculty") { Item item = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(itemId.Trim())); NameValueListField data = item.Fields["Faculty List"]; System.Collections.Specialized.NameValueCollection nameValueCollection = data.NameValues; var originalData = item.Fields["Faculty List"].Value; var splitEach = originalData.Split('&'); int index = 0; int selectedIndex = 0; int targetIndex = 0; foreach (string eachFaculty in splitEach) { if (eachFaculty.Contains(key + "=")) { selectedIndex = index; break; } index++; } if (movementTo == "Move Up") { targetIndex = selectedIndex - 1; } else if (movementTo == "Move Down") { targetIndex = selectedIndex + 1; } try { originalData = originalData.Replace(splitEach[selectedIndex], "ReplaceData=Data") .Replace(splitEach[targetIndex], splitEach[selectedIndex]) .Replace("ReplaceData=Data", splitEach[targetIndex]); using (new Sitecore.SecurityModel.SecurityDisabler()) { item.Editing.BeginEdit(); item.Fields["Faculty List"].Value = originalData; item.Editing.EndEdit(); item.Editing.AcceptChanges(); Sitecore.Data.Managers.ItemManager.SaveItem(item); } } catch { } } // // Add multiple faculty in a section // if (!String.IsNullOrEmpty(itemId) && !String.IsNullOrEmpty(value) && type == "Add Multiple Faculty") { value = value.Trim(); var ids = value.Split(','); int isNumeric; if (ids.Length > 0) { Item item = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(itemId.Trim())); foreach (string id in ids) { if (int.TryParse(id, out isNumeric)) { using (new Sitecore.SecurityModel.SecurityDisabler()) { item.Editing.BeginEdit(); try { if (String.IsNullOrEmpty(item.Fields["Faculty List"].Value)) { item.Fields["Faculty List"].Value = id + "=;dump;"; } else { item.Fields["Faculty List"].Value = item.Fields["Faculty List"].Value + "&" + id + "=;dump;"; } } finally { item.Editing.EndEdit(); item.Editing.AcceptChanges(); Sitecore.Data.Managers.ItemManager.SaveItem(item); } } } } } } } return(PartialView(facultyList)); }
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); } }
/// <summary> /// Initializes a new instance of the <see cref="NameValueListProperty"/> class. /// </summary> /// <param name="field">The field to wrap.</param> public NameValueListProperty(Field field) : base(field) { this.nameValueListField = field; }
/// <inheritdoc /> /// <summary> /// Initializes a new instance of the <see cref="NameValueListProperty"/> class. /// </summary> /// <param name="field">The field to wrap.</param> public NameValueListProperty(Field field) : base(field) { _nameValueListField = field; }