0

I have modified Magento_Catalog/templates/product/list.phtml. I added this code:

/** @var $pagerBlock Magento\Theme\Block\Html\Pager */
$pagerBlock = $this->getLayout()->createBlock("Magento\Theme\Block\Html\Pager");
$pagerBlock->setCollection($_productCollection);

Which gives me the pager block for the catalog page I'm on. Which seemed to work. The method getNextPageUrl returns the correct page.

However, in a catalog of only 2 pages everything goes wrong. On page 1 and 2 (which is the last page) of my catalog the pager block returns true for all of these three methods:

$pagerBlock->isLastPage();
$pagerBlock->getLastPageNum();
$pagerBlock->getCurrentPage();

getNextPageUrl returns page one (https://domain.loc/en/singleplayer/preschool-games.html?p=1)

What's going on?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.