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?



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.


2 Answers 2


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:


  • 1
    To complete Luke's answer, omit the .all() call here, and pass the main VariantQuery object to the paginate template tag: {% paginate craft.variants({ product: product }) as pageInfo, pageVariants %} (Otherwise, you're back at square one, with a simple array!) Commented Dec 17, 2018 at 18:40
  • Thanks both. @AugustMiller your tag worked perfectly. Thanks!
    – Jay
    Commented Dec 19, 2018 at 12:13
  • I ended up going with {% paginate craft.variants({ product: product }).limit(12) as pageInfo, pageVariants %} to get the pagination to work properly by the way. :)
    – Jay
    Commented Dec 19, 2018 at 16:36

I'm interested how you are calling variants - have you tried using craft.variants.limit(12) versus variants.limit(12)? Craft Docs - sample variant query

Here is another example where Brad shares insights on paginating after using the search service.

  • Updated question.
    – Jay
    Commented Dec 14, 2018 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.