How to Get Current Block in Observer in Magento

magento-1.7magento-1.8magento-1.9

I want get current block in my observer, for example I have observe event

        <catalog_block_product_list_collection>
            <observers>
                <mycompany_category_list_collection>
                    <type>singleton</type>
                    <class>mycompany/category</class>
                    <method>sendProductImpressionAfterLoad</method>
                </mycompany_category_list_collection>
            </observers>
        </catalog_block_product_list_collection>

this is event dispath in block reder category….
I can get this block class, name, file, type or other information for help me indetification this block in my method.

Best Answer

Try your stuff with below example:

public function coreBlockAbstractToHtmlBefore(Varien_Event_Observer $observer) {

 $block = $observer->getBlock();

if($block instanceof Mage_Page_Block_Html_Pager) {
        $collection = $block->getCollection();
        $pages = $block->getPages();
    }

}