Skip to content

Commit

Permalink
VCST-2009: single value variations fix (#18)
Browse files Browse the repository at this point in the history
* a single variation not return issue fixed

VariationBinder was not return the variation id if it was a single value

* fix: refactor

---------

Co-authored-by: AhmedElrakhawy <106417327+AhmedElrakhawy@users.noreply.github.com>
Co-authored-by: Kutasina Elena <62027488+ekuvirto@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 23, 2024
1 parent 9ba8410 commit 9af4dd4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/VirtoCommerce.XCatalog.Core/Binding/VariationsBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ public virtual object BindModel(SearchDocument searchDocument)
{
var fieldName = BindingInfo.FieldName;

return searchDocument.TryGetValue(fieldName, out var value) && value is object[] objs
? objs.Select(x => (string)x).ToList()
: Enumerable.Empty<string>().ToList();
var result = searchDocument.TryGetValue(fieldName, out var value)
? value switch
{
object[] objs => objs.Select(x => (string)x).ToList(),
string str => [str],
_ => Enumerable.Empty<string>().ToList()
}
: Enumerable.Empty<string>().ToList();

return result;
}
}
}

0 comments on commit 9af4dd4

Please sign in to comment.