0

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.

3
  • on which file this is show the error
    – Amit Bera
    Commented Oct 30, 2014 at 11:14
  • It shows on product detail page Commented Oct 30, 2014 at 11:19
  • Please post the full catalog.xml catalog_product_view section and any snippets from other layout xml files like a custom theme one that might influence this. My guess is somewhere the reference is being added to a parent group. Have you tried using another name or as for the block? Commented Apr 14, 2015 at 6:45

2 Answers 2

1

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>
1
  • Thanks for the code, But this also not worked.. Commented Oct 31, 2014 at 5:50
0

Please use the following code

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

in place of

<?php echo $this->getChildHtml('related'); ?>
1
  • I did not agree with your solution because I am using as="related" in xml, so both option will work. There is another issue in my code. Which I am not able to figure out. Commented Oct 31, 2014 at 5:48

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.