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
.all()call here, and pass the mainVariantQueryobject to thepaginatetemplate tag:{% paginate craft.variants({ product: product }) as pageInfo, pageVariants %}(Otherwise, you're back at square one, with a simple array!) – August Miller Dec 17 '18 at 18:40{% paginate craft.variants({ product: product }).limit(12) as pageInfo, pageVariants %}to get the pagination to work properly by the way. :) – Jay Dec 19 '18 at 16:36