Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a value from a parent Block

Tags:

magento

I'm facing some difficult to accomplish this apparently easy task.

I'm in a nested block ( suggestion.phtml ) and I want to get a value ( number of search result, and so the collection count) from a parent block ( result.phtml )

I'm wrong or there is not an easy way here ?

like image 936
WonderLand Avatar asked Nov 29 '12 10:11

WonderLand


1 Answers

Ok solved.

It is possible to access a parent block with:

$this->getParentBlock();

So in this particular scenario:

$searchCount = $this->getParentBlock()
    ->getParentBlock()
    ->getParentBlock()
    ->getResultCount();
like image 166
WonderLand Avatar answered Oct 19 '22 22:10

WonderLand