My block file path is


In this file method name is getId()

Now how to call call this method in controller?

2 Answers 2


Hi you can call this block by using below code at controller.



Block Prefix is define at app\code\local\Company\Modulename\Block\Product\View\View.php under tag

        <blockPrefix><!-- guess that modulePrefix is your module block prefix -->

See at how to call a block check at here


If your block is already attached to the action of the controller you can call it like


If the block has nothing to do with your current action you can call it like :

  • 2
    I'm not sure the second example works in, at least not in The method's doc block says it's deprecated and to use self::helper() which is odd in itself, because blocks and helpers are different things!
    – scrowler
    Mar 24, 2016 at 1:32

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.