# Getting all published Variants

**URL:** <https://forum.litium.com/t/getting-all-published-variants/529>\
**Category:** Questions\
**Tags:** litium-7\
**Created:** [January 29, 2019, 7:17am UTC](https://forum.litium.com/t/getting-all-published-variants/529 "2019-01-29T07:17:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PontvsXlent](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@PontvsXlent](https://forum.litium.com/u/PontvsXlent)\
**Post date:** [January 29, 2019, 7:17am UTC](https://forum.litium.com/t/getting-all-published-variants/529/1 "2019-01-29T07:17:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PontvsXlent](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@PontvsXlent](https://forum.litium.com/u/PontvsXlent)\
**Post date:** [January 29, 2019, 2:44pm UTC](https://forum.litium.com/t/getting-all-published-variants/529/2 "2019-01-29T14:44:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/artur/32/948_2.png) [@Artur](https://forum.litium.com/u/Artur)\
**Post date:** [January 28, 2020, 5:20pm UTC](https://forum.litium.com/t/getting-all-published-variants/529/3 "2020-01-28T17:20:04Z")

</div>

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.
