protected virtual void AddStatisticsFieldsWhenMissing(BulkLoadItem bulkItem, string language, int versionNumber = 1) { var user = global::Sitecore.Context.User.Name; if (bulkItem.GetField(FieldIDs.Created.Guid, language, versionNumber) == null) { bulkItem.AddVersionedField(FieldIDs.Created.Guid, language, versionNumber, DateUtil.IsoNow, name: "__Created"); } if (bulkItem.GetField(FieldIDs.CreatedBy.Guid, language, versionNumber) == null) { bulkItem.AddVersionedField(FieldIDs.CreatedBy.Guid, language, versionNumber, user, name: "__Created by"); } if (bulkItem.LoadAction == BulkLoadAction.Update || bulkItem.LoadAction == BulkLoadAction.UpdateExistingItem) { if (bulkItem.GetField(FieldIDs.UpdatedBy.Guid, language, versionNumber) == null) { bulkItem.AddVersionedField(FieldIDs.UpdatedBy.Guid, language, versionNumber, user, name: "__Updated"); } if (bulkItem.GetField(FieldIDs.Updated.Guid, language, versionNumber) == null) { bulkItem.AddVersionedField(FieldIDs.Updated.Guid, language, versionNumber, DateUtil.IsoNowWithTicks, name: "__Updated by"); } } }
protected virtual void AddStatisticsFieldsWhenMissing(BulkLoadItem bulkItem, string language, int versionNumber = 1) { var user = Sitecore.Context.User.Name; // Make sure revision is updated when item is created or updated so that smart publish works. // Unicorn doesn't track revisions, so we need to generate one ourselves. if (bulkItem.GetField(FieldIDs.Revision.Guid, language, versionNumber) == null) { bulkItem.AddVersionedField(FieldIDs.Revision.Guid, language, versionNumber, Guid.NewGuid().ToString("D"), name: "__Revision", postProcessor: x => x.DependsOnCreate = x.DependsOnUpdate = true); } if (bulkItem.GetField(FieldIDs.Created.Guid, language, versionNumber) == null) { bulkItem.AddVersionedField(FieldIDs.Created.Guid, language, versionNumber, DateUtil.IsoNow, name: "__Created", postProcessor: x => x.DependsOnCreate = true); } if (bulkItem.GetField(FieldIDs.CreatedBy.Guid, language, versionNumber) == null) { bulkItem.AddVersionedField(FieldIDs.CreatedBy.Guid, language, versionNumber, user, name: "__Created by", postProcessor: x => x.DependsOnCreate = true); } if (bulkItem.GetField(FieldIDs.Updated.Guid, language, versionNumber) == null) { bulkItem.AddVersionedField(FieldIDs.Updated.Guid, language, versionNumber, DateUtil.IsoNow, name: "__Updated", postProcessor: x => x.DependsOnCreate = x.DependsOnUpdate = true); } if (bulkItem.GetField(FieldIDs.UpdatedBy.Guid, language, versionNumber) == null) { bulkItem.AddVersionedField(FieldIDs.UpdatedBy.Guid, language, versionNumber, user, name: "__Updated by", postProcessor: x => x.DependsOnCreate = x.DependsOnUpdate = true); } }