Use paginate with information from metafield

Hello,

I have put an if statement in my collection template that:

if product option 2 isn't blank, show all the variants from option 2 as separate products on the collection page.

Now since pagination works based on the number of products, it'll show a different number of items on each page. ( which I expected it and technically is working as it should)

Now to basically organize my collection pages, I was thinking of putting some data in collection metafields and paginate based on that.

Example: a collection has 20 products, 10 of these products have 2 variants, so a total of 30 variants/items to show on the collection page.

Now paginate this collection by 10

  1. A normal collection would show 2 pages with 10 items each

  2. My old code would show 2 pages with the first one having 13 items and the second one having 17.

  3. What this new code will do, show 3 pages with 10 items each

So basically, my questions are:

  1. Is paginating based on data from a metafield possible?
  2. If yes
    1. what sort of data should be there? ( I was thinking about uploading the total number of items there and paginate based on that)
    2. Will this affect the page load speed

If you want to see how the collection pages look like now here's my website: COLLECTION PAGE 

Thanks for all the help in advance

-Like and Mark as an Accepted Solution if my reply is helpful
I'm not an expert, these are my own experiences or codes that I gathered from others. I'm using Debut.
I have my own online pet supply store check it out at
PETLANTIS.CA
0 Likes