Skip to content

Instantly share code, notes, and snippets.

@NaibafCH
Created December 19, 2016 11:47
Show Gist options
  • Save NaibafCH/4c6c28dc2eb97aa423bf3a1c2637d0f3 to your computer and use it in GitHub Desktop.
Save NaibafCH/4c6c28dc2eb97aa423bf3a1c2637d0f3 to your computer and use it in GitHub Desktop.
using System;
using Sitecore.ContentSearch.ComputedFields;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
namespace Sitecore.ContentSearch.Search.ComputedFields
{
public class AutoCompleteTitle : IComputedIndexField
{
public object ComputeFieldValue(IIndexable indexable)
{
if (indexable == null) throw new ArgumentNullException("indexable");
var scIndexable = indexable as SitecoreIndexableItem;
if (scIndexable == null)
{
Log.Warn(
this + " : unsupported IIndexable type : " + indexable.GetType(), this);
return false;
}
var item = (Item)scIndexable;
if (item == null)
{
Log.Warn(
this + " : unsupported SitecoreIndexableItem type : " + scIndexable.GetType(), this);
return false;
}
if (string.Compare(item.Database.Name, "core", StringComparison.OrdinalIgnoreCase) == 0)
{
return false;
}
return item["Title"];
}
public string FieldName { get; set; }
public string ReturnType { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment