Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How do I add a new block on the product page ? 
 
Luc.Barry
Jr. Member
 
Total Posts:  1
Joined:  2011-02-13
 

Hi,

I have trouble to add a new block to the product page.

What I was doing first, was to add my code at the end of the “template/catalog/product/view.phtml” file and it works perfectly. But now, what I’m trying to do is separate the code in a module that would be easier to export.

So I put my code in “template/mymodule/mytemplate.phtml” and I created a layout file “layout/mymodule.xml” :

<layout version="0.1.0">
  <
catalog_product_view>
    <
reference name="product.info">
      <
block type="mymodule/product_view" 
          
name="product.info.mymodule" 
          
template="mymodule/mytemplate.phtml"/>
    </
reference>
  </
catalog_product_view>
</
layout>

And added as well this to “Mymodule/etc/my config.xml” :

<?xml version="1.0"?>
<config>
  <
modules>
    <
Mynamespace_Mymodule>
      <
version>0.9</version>
    </
Mynamespace_Mymodule>
  </
modules>
  <
frontend>
    <
layout>
      <
updates>
    <
test>
      <
file>mymodule.xml</file>
    </
test>
      </
updates>
    </
layout>
  </
frontend>
  <global>
    <
blocks>
      <
catalog>
    <
rewrite>
      <
product_view>Mynamespace_Mymodule_Catalog_Product_View</product_view>
    </
rewrite>
      </
catalog>
    </
blocks>
  </global>
</
config>

Right now when I want to access a product page, I have this error :
Fatal error: Call to a member function addToChildGroup() on a non-object in /var/www/test/magento/app/code/core/Mage/Core/Block/Abstract.php on line 649

How can I fix this?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top