Reputation: 1
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.
Upvotes: 0
Views: 3906
Reputation: 480
you can call block in template directly
$bestseller = $this->getLayout()->getBlock('bestSeller/index');
$bestseller->getBestsellerProducts();
Upvotes: 0
Reputation: 3836
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();
Upvotes: 1