I need to replace a few values in a few blocks, starting with category/view or more specifically product/list. I found an excellent writeup by Ben Marks, but as far as I can tell, I can only observe the abstract event and not specify this for specific blocks. This would be my ideal situation. Alternatively, I'd like the method to be a no-op as soon as possible, if it's not the block I want. Is $observer->getBlock()->getName() or something to that effect, my only option or are the cheaper ways to filter my block?

1 Answer 1


I haven't found a "less expensive" way than core_block_to_html_after, unless the block itself has some custom event it dispatches. You could rewrite the block and have it dispatch an event that you'd want but then you may as well just stick all the logic there. That approach has its own drawbacks as well.

You should set the event only in the area that you need it if possible:


This would prevent the method from being called in the admin area where the block type/name you're looking for isn't going to be rendered.

I usually check for class types if appropriate:

if ($observer->getBlock() instanceof Mage_Catalog_Block_Category_View)

I wonder if (and hope) that would perform better than $observer->getBlock()->getName() or similar.

  • Aha, thanks. I was wondering if I needed a <reference /> of some kind but that should work fine. I don't want to rewrite the block if possible, cause this isn't an extension one would expect a block rewrite from (template, new functionality or similar) so in any real world store, I'd probably generate a conflict if I did. Thank you very much.
    – user4351
    Jan 22, 2014 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.