1
1
using Umbraco . Cms . Core . Models ;
2
- using Umbraco . Cms . Core . Models . PublishedContent ;
3
2
using Umbraco . Cms . Core . PropertyEditors ;
3
+ using Umbraco . Cms . Core . Services ;
4
4
using Umbraco . Cms . Integrations . Search . Algolia . Providers ;
5
5
6
6
namespace Umbraco . Cms . Integrations . Search . Algolia . Services
7
7
{
8
8
public class AlgoliaSearchPropertyIndexValueFactory : IAlgoliaSearchPropertyIndexValueFactory
9
9
{
10
10
private readonly PropertyEditorCollection _propertyEditorsCollection ;
11
-
12
11
private readonly ConverterCollection _converterCollection ;
13
12
13
+ private readonly ILocalizationService _localizationService ;
14
+ private readonly IContentTypeService _contentTypeService ;
15
+
14
16
public AlgoliaSearchPropertyIndexValueFactory (
15
17
PropertyEditorCollection propertyEditorCollection ,
16
- ConverterCollection converterCollection )
18
+ ConverterCollection converterCollection ,
19
+ ILocalizationService localizationService ,
20
+ IContentTypeService contentTypeService )
17
21
{
18
22
_propertyEditorsCollection = propertyEditorCollection ;
19
-
20
23
_converterCollection = converterCollection ;
24
+ _localizationService = localizationService ;
25
+ _contentTypeService = contentTypeService ;
21
26
}
22
27
23
28
public virtual KeyValuePair < string , object > GetValue ( IProperty property , string culture )
24
29
{
30
+ var availableCultures = _localizationService . GetAllLanguages ( ) . Select ( p => p . IsoCode ) ;
31
+ IDictionary < Guid , IContentType > contentTypeDictionary = _contentTypeService . GetAll ( ) . ToDictionary ( x => x . Key ) ;
32
+
25
33
var propertyEditor = _propertyEditorsCollection . FirstOrDefault ( p => p . Alias == property . PropertyType . PropertyEditorAlias ) ;
26
34
if ( propertyEditor == null )
27
35
{
@@ -35,8 +43,22 @@ public virtual KeyValuePair<string, object> GetValue(IProperty property, string
35
43
return new KeyValuePair < string , object > ( property . Alias , result ) ;
36
44
}
37
45
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
40
62
if ( indexValues == null || ! indexValues . Any ( ) ) return new KeyValuePair < string , object > ( property . Alias , string . Empty ) ;
41
63
42
64
var indexValue = indexValues . First ( ) ;
0 commit comments