I have developed a module to overwrite a controller. I have the next route: Lecasa/Javinewlistproductcontroller/Block/Catalog/Product/List.phtml

This List.phtml file is: class Lecasa_Javinewlistproductcontroller_Block_Catalog_Product_List extends Mage_Catalog_Block_Product_List

I have been trying to use a function that I created in this List.phtml but i did not find the way to call it. Then I copied this one in Lecasa/Javinewlistproductcontroller/Helper/Data.php, I configured all files but when I used Mage::helper(...)->function(), the magento system added the Mage_ prefix to the helper class. Then, as a last alternative, I would like to know how I can call the function which is created at Lecasa/Javinewlistproductcontroller/Block/Catalog/Product/List.phtml directly from the rwd/.../List.phtml.



First of all you should rename your file for your block to List.php, .phtml is the ending for templates.

In order to overwrite the Magento block Mage_Catalog_Block_Product_List you should add a rewrite tag into your modules config.xml in the global section:


With this done you can use your method everywhere a block of type Mage_Catalog_Block_Product_List is available, for example in a product list template using $this->yourMethod().

If you want to add your new block to the layout you don't need to add the above rewrite. You can just a <block type="yourmodule/catalog_product_list" template="..."> into an appropriate layout xml file. Then you can use your method in the configured template via $this->yourMethod()

I hope that helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.