Pardon me for my lack of Magento knowledge in advance. I'm adding custom functionality to a theme like this:


class Myvendor_Mymodule_Block_Catalog_Product_View extends Mage_Catalog_Block_Product_View
  public function myCustomFunction() {
    // Custom functionality

This function is called in a template like this:


<?php echo $this->myCustomFunction(); ?>

However, in Xdebug, $this always points to Mage_Catalog_Block_Product_View

What are the cases in which the custom module's block is not recognized, and $this defaults to the Mage block instead?

  • The custom module is active at app/etc/modules/Myvendor_Mymodule.xml
  • The custom block is specified at app/code/local/Myvendor/Mymodule/etc/config.xml: <blocks> <myvendor_mymodule> <class>Myvendor_Mymodule_Block</class> </myvendor_mymodule> </blocks>

  • The public function name does not conflict with any other function names.

  • It's necessary for the template to be located inside the myvendor_mymodule package.

1 Answer 1


You need to rewrite Mage_Catalog_Block_Product_View class, then you can use this way

<?php echo $this->myCustomFunction(); ?>

Clear cache.

  • Quick answer and fully working solution. Very much appreciated! Commented Apr 3, 2017 at 14:53

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.