From within an observer, I can use


to get a block for manipulation.

This method uses the block's name as a reference to identify and retrieve it from the layout. In most cases this is OK, but if Mage_Core_Model_Layout's createBlock method is called without a name, which it is in some core code, the block is given the name ANONYMOUS_n, where n is the number of blocks in the layout object.

Is there any way I can retrieve the anonymous block within my observer?

  • If it's a block of a specific type you could potentially use the block type I reckon Nov 2, 2016 at 11:50
  • @RaphaelatDigitalPianism The get block method Mage_Core_Model_Layout takes a block name as an argument. There is also a getAllBlocks method, so maybe I could use that and filter on the block type.
    – Dom
    Nov 2, 2016 at 11:53
  • yeah I was referring to the getAllBlocks method. Nov 2, 2016 at 11:54
  • which is the event that you are observing ? Answer is fully depend on that !!! Nov 2, 2016 at 12:25
  • @RajeevKTomy actually I'd be interested in an answer which is independent of the event being observed!!! I happen to be observing the resource_get_tablename event. I understand that if I were observing core_layout_block_create_after, then the block would be passed within the observer argument.
    – Dom
    Nov 2, 2016 at 13:08

1 Answer 1


Not without more information about the block. This could be a combination of parent block and block type (via getChildren() of the parent), or from where it was created (you could observe core_layout_block_create_after to monitor creation of anonymous blocks)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.