# Using observer, how to get the current pager with loaded product collection

Using an observer how can i get the current pager block with its loaded product collection on a category page?

I want to check the total number of pages on a category page before it is loaded.

## 1 Answer

You could try listening to the event core_block_abstract_to_html_before and then checking if the block given is of instance Mage_Page_Block_Html_Pager.

This block has a function getCollection which would give you the current collection and the function getPages which will give you an array of all the page ids.

public function coreBlockAbstractToHtmlBefore(Varien_Event_Observer $observer) {$block = $observer->getBlock(); if($block instanceof Mage_Page_Block_Html_Pager) {
$collection =$block->getCollection();
$pages =$block->getPages();
}
}