Hi @melaleuca5,
You cannot get more than 500 entries in one request. That’s why paging is necessary.
The code sets the page index to 1 initially and then starts iterating over the entries, increasing $page_index by one at the end of each iteration. And so, during the first iteration, you’ll get the first 500 entries to process [page 1], in the second, entries 500 to 1000 [page 2] and so forth until all entries are processed.