HomeGuides
Submit Documentation FeedbackJoin Developer CommunityLog In

Filtering catalog content

This topic describes how to filter catalog content in a Commerce solution using the Optimizely Search & Navigation (formerly Find).

The examples use predefined filters to narrow results on catalog content.

Markets

Filtering content on current market:

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

Filtering content on 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 withprice 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(c => c.ID, contentReference.ID));

Filtering parent bundles:

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

Packages

Filtering package entries:

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

Filtering parent packages:

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

Node relations

Filtering parent node relations:

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

Filtering child node relations:

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

Did this page help you?