I have a magento community 2.4 and I’m trying to customize the first page of the product list in the category page so that the first page uses a different pagination from the rest of the collection. Unfortunately, no matter what I do, nothing seems to work, my code either throws an error on the PriceBox class or it simply doesn’t work. I’ve tried with a plugin on the beforeLoad() on the product collection, a afterGetLoadedProductCollection() on the ProductList class, an afterGetLimit() on the Toolbar. Of all these, only the afterGetLimit() on the Toolbar seems to have some effect: I can change the first page with the pageSize that I want, but the same pageSize is then inherited by the subsequent pages. I’ve tried using setPage(), getSelect()->setLimit() but the problem is still the same: my code works on the first page, but not on the other pages. Example:
if ($currentPage == 1) {
$collection->getSelect()->limit(11, 0);
} else {
$collection->getSelect()->limit(12, 11);
}
So, what I would expect is that the first page shows the first eleven products of the collection, instead of 12 products, and the 12th product should be pushed on the second page, so the second page should show 12 products starting from the 12th product.
What happens instead:
- the first page shows the first 11 products (correct)
- the second page starts from the 13th product, like the first page still had 12 products instead of 11. Basically, the 12th product is lost
So my question is: is there a way to tell magento to give me a pagination of 11 products on the first page and a pagination of 12 products on all the others?