0

I have an Observer and I must get the number of pages (I need to know if there is > 1 page) in it. I tried on both collection and pager but no success :

public function __construct(
    \Magento\Framework\App\Request\Http $request,
    \Magento\Framework\View\Page\Config $layoutFactory,
    LayerResolver $layerResolver,
)
{
    $this->request = $request;
    $this->layoutFactory = $layoutFactory;
    $this->catalogLayer = $layerResolver->get();
}

public function execute(Observer $observer)
{
$this->catalogLayer->getProductCollection()->getLastPageNumber()
}

By trying this it gave me the result "1" but this is not the good one.

Any idea on how I should do it?

  • please attach your code – Rk Rathod May 16 at 15:17
  • I updated my code! – Misaka May 17 at 7:30

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.