DFO 3.1.0 - 9 Indexing Assets with Optimizely Find


DAM for Optimizely works well with Optimizely Find. To get the most out of it you might want to even add the individual assets to the index. This can be done by adding a ReindexInformation provider as shown below.

ReindexInformation Provider
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using EPiServer;
using EPiServer.Core;
using EPiServer.Find.Cms;
using EPiServer.ServiceLocation;
using EPiServer.Web;

namespace Digizuite.Episerver.Examples.Find
{
    [ServiceConfiguration(typeof(IReindexInformation), Lifecycle = ServiceInstanceScope.Singleton)]
    public class DigizuiteReindexInformation : IReindexInformation
    {
        public IContentLoader ContentLoader { get; set; }

        public IDigizuiteClient Client { get; set; }

        public DigizuiteReindexInformation(IContentLoader contentloader, IDigizuiteClient client)
        {
            this.ContentLoader = contentloader;
            this.Client = client;
        }

        public virtual IEnumerable<ReindexTarget> ReindexTargets
        {
            get
            {
                if (Client.Folders == null)
                    return new List<ReindexTarget>();

                var contentLinks = new List<ContentReference>();
                var languages = Client.Languages.Select(lang => new CultureInfo(lang.LanguageShort)).ToList();

                var entrypoint = DigizuiteContentProvider.GetEntryPoint();
                var childrens = ContentLoader.GetDescendents(entrypoint);
                contentLinks.AddRange(childrens);

                return new List<ReindexTarget>()
                {
                    new ReindexTarget
                    {
                        ContentLinks = contentLinks,
                        Languages = languages,
                        SiteDefinition = SiteDefinition.Empty
                    }
                };
            }
        }

        public virtual ContentReference Root
        {
            get
            {
                var entrypoint = DigizuiteContentProvider.GetEntryPoint();
                return entrypoint;
            }
        }
    }
}