11using Umbraco . Cms . Core . Models ;
2- using Umbraco . Cms . Core . Models . PublishedContent ;
32using Umbraco . Cms . Core . PropertyEditors ;
3+ using Umbraco . Cms . Core . Services ;
44using Umbraco . Cms . Integrations . Search . Algolia . Providers ;
55
66namespace Umbraco . Cms . Integrations . Search . Algolia . Services
77{
88 public class AlgoliaSearchPropertyIndexValueFactory : IAlgoliaSearchPropertyIndexValueFactory
99 {
1010 private readonly PropertyEditorCollection _propertyEditorsCollection ;
11-
1211 private readonly ConverterCollection _converterCollection ;
1312
13+ private readonly ILocalizationService _localizationService ;
14+ private readonly IContentTypeService _contentTypeService ;
15+
1416 public AlgoliaSearchPropertyIndexValueFactory (
1517 PropertyEditorCollection propertyEditorCollection ,
16- ConverterCollection converterCollection )
18+ ConverterCollection converterCollection ,
19+ ILocalizationService localizationService ,
20+ IContentTypeService contentTypeService )
1721 {
1822 _propertyEditorsCollection = propertyEditorCollection ;
19-
2023 _converterCollection = converterCollection ;
24+ _localizationService = localizationService ;
25+ _contentTypeService = contentTypeService ;
2126 }
2227
2328 public virtual KeyValuePair < string , object > GetValue ( IProperty property , string culture )
2429 {
30+ var availableCultures = _localizationService . GetAllLanguages ( ) . Select ( p => p . IsoCode ) ;
31+ IDictionary < Guid , IContentType > contentTypeDictionary = _contentTypeService . GetAll ( ) . ToDictionary ( x => x . Key ) ;
32+
2533 var propertyEditor = _propertyEditorsCollection . FirstOrDefault ( p => p . Alias == property . PropertyType . PropertyEditorAlias ) ;
2634 if ( propertyEditor == null )
2735 {
@@ -35,8 +43,22 @@ public virtual KeyValuePair<string, object> GetValue(IProperty property, string
3543 return new KeyValuePair < string , object > ( property . Alias , result ) ;
3644 }
3745
38- IEnumerable < KeyValuePair < string , IEnumerable < object > > > indexValues = propertyEditor . PropertyIndexValueFactory . GetIndexValues ( property , culture , null , true ) ;
39-
46+ IEnumerable < KeyValuePair < string , IEnumerable < object > > > indexValues =
47+ #if NET6_0 || NET7_0
48+ propertyEditor . PropertyIndexValueFactory . GetIndexValues (
49+ property ,
50+ culture ,
51+ null ,
52+ true ) ;
53+ #else
54+ propertyEditor . PropertyIndexValueFactory . GetIndexValues (
55+ property ,
56+ culture ,
57+ null ,
58+ true ,
59+ availableCultures ,
60+ contentTypeDictionary ) ;
61+ #endif
4062 if ( indexValues == null || ! indexValues . Any ( ) ) return new KeyValuePair < string , object > ( property . Alias , string . Empty ) ;
4163
4264 var indexValue = indexValues . First ( ) ;
0 commit comments