从父块获取值

Won*_*and 8 magento

我面临着一些难以完成这项看似简单的任务.

我在嵌套块(suggestion.phtml)中,我想从父块(result.phtml)获取一个值(搜索结果的数量,以及集合计数)

我错了,或者这里没有简单的方法?

Won*_*and 26

好的解决了.

可以通过以下方式访问父块:

$this->getParentBlock();
Run Code Online (Sandbox Code Playgroud)

所以在这个特殊场景中:

$searchCount = $this->getParentBlock()
    ->getParentBlock()
    ->getParentBlock()
    ->getResultCount();
Run Code Online (Sandbox Code Playgroud)