Hide menu Last updated: Nov 03 2015

Filtering catalog content

This topic provides examples of filtering catalog content in a Commerce solution using the Find search provider EPiServer.Find.Commerce. The examples use predefined filters to narrow results on catalog content.

Markets

Filtering content on market:

var results = SearchClient.Instance.Search<MyTestType>().FilterOnCurrentMarket().GetContentResult();

Filtering content on current market:

var result = SearchClient.Instance.Search<VariationContent>()
    .Filter(x => x.AvailableMarkets().MatchContained(v => v.Value, "market"));
Pricing

Filtering content with currency:

var result = SearchClient.Instance.Search<VariationContent>()
    .Filter(x => x.DefaultPrice().UnitPrice.Currency.Match(currency));

Filtering content with price less than:

var result = SearchClient.Instance.Search<VariationContent>()
    .Filter(x => x.DefaultPrice().UnitPrice.LessThan(2));
Filtering content with price greater than:
var result = SearchClient.Instance.Search<VariationContent>()
    .Filter(x => x.DefaultPrice().UnitPrice.GreaterThan(2));

Filtering content with price in range:

var result = SearchClient.Instance.Search<VariationContent>()
    .Filter(x => x.DefaultPrice().UnitPrice.InRange(2, 4))

Bundles

Filtering bundle entries:

var result = SearchClient.Instance.Search<BundleContent>()
    .Filter(x => x.BundleEntries().MatchContained(contentReference)

Filtering parent bundles:

var result = SearchClient.Instance.Search<EntryContentBase>() .Filter(x => x.ParentBundles().MatchContained(contentReference)

Packages

Filtering package entries:

var result = SearchClient.Instance.Search<PackageContent>()
    .Filter(x => x.PackageEntries().MatchContained(contentReference)

Filtering parent packages:

var result = SearchClient.Instance.Search<EntryContentBase>()
    .Filter(x => x.ParentPackages().MatchContained(contentReference)

Node relations

Filtering parent node relations:

var result = SearchClient.Instance.Search<BundleContent>()
    .Filter(x => x.ParentNodeRelations().MatchContained(contentReference)

Filtering child node relations:

var result = SearchClient.Instance.Search<BundleContent>()
    .Filter(x => x.ChildNodeRelations().MatchContained(contentReference)

Comments