Possible to paginate product variants in Craft Commerce 2? I am currently in the process of building a commerce 2 site with a very detailed level of nesting in the product options so we're looking to list all variants for a product. (Sounds silly, but it works in this case!)

However, while trying to use paginate, I'm getting the following error:

Impossible to invoke a method ("limit") on an array.


Here is my markup:

{% paginate variants.limit(12) as pageInfo, pageEntries %}


Is it even possible to paginate variants?

Thanks

EDIT

We are getting all the product variants as follows:

{% set variants = product.variants %}


But if we use the limit here outside of the pagination, won't that mean we will always get the same first 12 items. Whereas we need to limit it within the paginator so we get the first 12, the next 12 etc etc.

Cheers
product.variants returns the variants for the product as an array only. It is not like a element relationship field which returns an element query.

If you want to use a element query of variants for a particular product you can do:

craft.variants.product(product).all