问题描述:

I have block class

 class GauravKhatri_BestSeller_Block_Index extends Mage_Core_Block_Template

{

public function getBestsellerProducts()

{

//Here is my code

}

}

I have bestseller.phtml file.

I want to get result of that function on phtml file.

Can anyone help me how to do it.

网友答案:

If this template file "bestseller.phtml" is directly associated with your block. like below example:

<block type="bestSeller/index" name="bestseller" template="bestseller.phtml "/>  

then you can access all the functions of this block class GauravKhatri_BestSeller_Block_Index in associated template using $this. like example:

$this->getBestsellerProducts();
网友答案:

you can call block in template directly

$bestseller = $this->getLayout()->getBlock('bestSeller/index');
$bestseller->getBestsellerProducts();
相关阅读:
Top