Last active
April 23, 2019 17:42
-
-
Save neilkillen/2cc341af7eaebf08f8a262a43f5c12bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected virtual ItemModel DoSearch(object value, Plugins.ResolveSitecoreItemEnhancedSettings resolveItemSettings, IItemModelRepository repository, ILogger logger, PipelineContext pipelineContext) | |
{ | |
if (!(GetValueReader(resolveItemSettings.MatchingFieldValueAccessor) is SitecoreItemFieldReader sitecoreItemFieldReader)) | |
{ | |
Log( | |
logger.Error, | |
pipelineContext, | |
"The matching field value accessor is not a valid Sitecore item field reader."); | |
return null; | |
} | |
string text = ConvertValueForSearch(value); | |
Log( | |
logger.Debug, | |
pipelineContext, | |
"Value converted for search.", | |
$"field: {sitecoreItemFieldReader.FieldName}", | |
$"original value: {value}", | |
$"converted value: {text}"); | |
Log( | |
logger.Debug, | |
pipelineContext, | |
"Starting search for item.", | |
$"field: {sitecoreItemFieldReader.FieldName}", | |
$"value: {text}"); | |
IEnumerable<ItemModel> enumerable = repository.Search(new ItemSearchSettings | |
{ | |
SearchFilters = | |
{ | |
new SearchFilter | |
{ | |
FieldName = sitecoreItemFieldReader.FieldName, | |
Value = text | |
}, | |
new SearchFilter | |
{ | |
FieldName = "TemplateID", | |
Value = resolveItemSettings.TemplateForNewItem.ToString() | |
} | |
} | |
}); | |
return enumerable?.FirstOrDefault(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment