Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

DAM for Optimizely works well with Optimizely Episerver Find. Out of the box, no assets from Digizuite will be indexed. Adding Digizuite assets to the index, can be done by adding a ReindexInformation provider as shown below. In the example below we use the IDigizuiteClientclass to access assets from Digizuite. The method Task<IEnumerable<ContentReference>> GetAllContentReferences(List<FacetRequest> facets = null) Client.GetAllAssetIds, is used for searhing getting all assets from digizuite , which then can be added to the index. Here we search for all assets of assettype “image” and add them to the index. If you dont send any parameters to GetAllContentReferences, then you get all assets that has been added to the Optimizely Episerver channel in Digizuite . You can read more about how to add filter to the search DC 5.8 SDK Asset search.backend.

ReindexInformation Provider
Code Block
languagec#
using Digizuite.Models;
using Digizuite.OptimizelySystem.Collections.Generic;
using EPiServer.Find.Cms;
using EPiServer.ServiceLocation;
using EPiServer.Web;
using System.Globalization;
using System.Linq;
using Digizuite.Episerver;
using Digizuite.Episerver.Helpers.Internal;
using EPiServer.Core;

namespace AlloyDevSiteNet6EpiserverSite.Business
{
    [ServiceConfiguration(typeof(IReindexInformation), Lifecycle = ServiceInstanceScope.Singleton)]
    public class DigizuiteReindexInformation : IReindexInformation
    {        
        public IDigizuiteClient Client { get; set; }
        public DigizuiteReindexInformation(IDigizuiteClient client)
        {
            this.Client = client;
        }

        public IEnumerable<ReindexTarget> ReindexTargets
        {
            get
            {
                   var languagesassets = Client.Languages.Select(lang => new CultureInfo(lang.LanguageCode)).ToList(GetAllAssetIds();
                if               
                var facets = new List<FacetRequest>((assets != null)
                {
                    newvar FacetRequest()searchResult =                    {
                        FacetMode = FacetMode.QueryOnly,assets.Select(asset => ConversionHelper.GetReferenceFromAssetId(asset.AssetId)).ToList();
                    var languages   Recursive = true,
                        SearchKey = "assetType",
= Client.Languages.Select(lang => new CultureInfo(lang.LanguageShort)).ToList();

                    return  Values = new List<string>{"image"}List<ReindexTarget>()
                    }{
                };        new ReindexTarget
         var assets = Client.GetAllContentReferences(facets).GetAwaiter().GetResult();            {
     return new List<ReindexTarget>()                 {    ContentLinks = searchResult,
              new ReindexTarget             Languages =  languages,
    {                        SiteDefinition ContentLinks = assets,SiteDefinition.Empty
                        Languages}
= languages,                   };
     SiteDefinition = SiteDefinition.Empty         }

          }                 }return null;
            }
        }

        public ContentReference Root
        {
            get
            {                
                return DigizuiteContentProvider.GetEntryPoint();
            }
        }
    }
}