Getting all published Variants

We have a pretty flat product importfile from the customers ERP, and need to unpublish all the variants that are not present in the file.
But to do that we would need all the variants to compare to the contents of the file, so is there any good way of fetching all the published (or just all) variants?

Litium version: 7.0.2

Nevermind, found a bad, but effective way by using the DataService query and “neq” with the Id filter to fetch them all.

I know you solved it by using DataService.

You can also get all the variants by using
var templateGuid = FieldTemplateService.Get<ProductFieldTemplate>(typeof(ProductArea), TemplateId)
var baseProducts = BaseProductService.GetByTemplate(templateId)
...
var variants = VariantService.GetByBaseProduct(baseproduct)

Not the most optimal but this way you got more control of what products but should be cached from what I understand.