0 results if 1 variant of 5 is excluded from search

We have extended our search a bit from the Accelerator. We added this to exclude products that are discontinued and have a stock of 0.

            var excludeTags = new ExcludeTagClause();
            request.FilterTags.Add(excludeTags);

            var excludeDiscontinuedTags = new MandatoryTagClause();
            excludeDiscontinuedTags.Tags.Add(new Tag(TagNames.GetTagNameForWarehouseQuantity(CurrentState.Current.WebSite.InventoryId), 0));
            excludeDiscontinuedTags.Tags.Add(new Tag(_fieldDefinitionService.Get("Discontinued").GetTagName(), true));
            excludeTags.Tags.Add(excludeDiscontinuedTags);

But then we have some products with many variants, and if one is discountinued and have a stock of 0 we get 0 results in the search cause of 1 variant.
How do I write so the result still gets a hit?

Litium version: 6.2.2

Perhaps if you change your query to define what to include instead of what to exclude?

A rangetag to include all items with quantity between 0-9999999999 and discontinued = false.

1 Like

I think you need to implement an IIndexingProviderPreProcessor as in Campaign prices stop working then adding custom IIndexingProviderPreProcessor to move the values from all the variants into one field that you are using for the filtering.