Search for variants without a category

I want to make a search query to list all variants that’s missing a category. How do I do that?
Everything else on the variant is ok, it’s marked as published etc.

Litium version: 6.9

Not sure on what your scenario is here, but you could use the search inside of Litium, there’s a filter for Category.

You could also use the data service if you want to do it programmatically, but keep in mind this hits the database directly.

using (var q = _dataService.CreateQuery<Variant>())
{
	q.Filter(filter =>
	{
		((IFilterDescriptorExpression)filter).AddExpression(new CategoryQueryExpressionInfo { OperatorName = "null" });
	});

	var res = q.ToSystemIdList();
}

Lucene only indexes actual values (not null or empty), so you would have to write a indexing processor that adds a default value if no category is set, and then search for that.

2 Likes

Tack! Precis vad jag var ute efter.
Det ska inte användas mot kund.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.