Skip to content

Instantly share code, notes, and snippets.

View mikaelnet's full-sized avatar

Mikael Högberg mikaelnet

View GitHub Profile
@mikaelnet
mikaelnet / FilteredSitecoreItemCrawler.cs
Last active May 10, 2020 07:54
Sitecore Filtered Item Crawler
using System;
using System.Collections.Generic;
using System.Linq;
using Sitecore;
using Sitecore.Collections;
using Sitecore.ContentSearch;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
public static class GuidUtils
{
/// <summary>
/// Creates a name-based UUID using the algorithm from RFC 4122 §4.3, using SHA1
/// (version 5). This is useful for creating predictive Guid based on content.
/// </summary>
/// <param name="namespaceId">A known namespace to create the UUID within</param>
/// <param name="name">The name (within the given namespace) to make the Guid from</param>
/// <returns></returns>
public static Guid Create(Guid namespaceId, string name)
@mikaelnet
mikaelnet / Sitecore-InvalidContentFieldData.sql
Last active November 2, 2022 00:47
Finds invalid content in the Sitecore database
DECLARE @SharedFieldId UniqueIdentifier = '{BE351A73-FCB0-4213-93FA-C302D8AB4F51}' /* Shared checkbox */
DECLARE @UnversionedFieldId UniqueIdentifier = '{39847666-389D-409B-95BD-F2016F11EED5}' /* unversioned checkbox */
DECLARE @TemplateFieldId UniqueIdentifier = '{455A3E98-A627-4B40-8035-E683A0331AC7}' /* Template field */
-- Find all templates WHERE both "Unversioned" AND "Shared" is selected:
-- "Shared" will have precedense, so the "Unversioned" checkbox can be removed
SELECT * FROM SharedFields
WHERE FieldId=@UnversionedFieldId AND [Value] = '1'
AND ItemId IN (SELECT ItemId FROM SharedFields WHERE FieldId=@SharedFieldId AND [Value]='1')