Magento – Fatal error: Call to a member function addToChildGroup() on a non-object

magento-1.9

I want to show some related product in magento theme.
For that I updated catalog.xml file with following code.

<reference name="content">
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
<block type="catalog/product_list_related" name="catalog.product.related" as="related" template="catalog/product/list/related.phtml"/>
</block>
</reference> 

And added below code in catalog/product/view.phtml file.

<?php echo $this->getChildHtml('related'); ?>

After this few changes I got this error

 Fatal error: Call to a member function addToChildGroup() on a non-object in magento/app/code/core/Mage/Core/Block/Abstract.php on line 815

Please suggest what could be the issue of this error.

Best Answer

Try using the following snippet for the related block xml it appears you are missing some information that this block needs.

<block type="catalog/product_list_related" name="catalog.product.related" as="related" after="product.info.upsell" template="catalog/product/list/related.phtml">
  <action method="setColumnCount">
    <columns>4</columns>
  </action>                    
  <action method="setItemLimit">
    <type>related</type>
    <limit>4</limit>
  </action>
</block>