Move Related Products to Centre Column in Magento

The contents of this article may be out of date. It has been archived and will no longer be updated, comments are closed and the page is provided for reference purposes only.

The default theme for Magento has the related products block on the left hand side which is not necessarily the best place for it. A more logical place to put related products is under the product description in the center column. It is simple to move the related products block but you need to know where to look.

This article assumes you are using the modern template as a starting point and the line numbers relate to Magento version 1.4.0.1. If this is not the case for you the path to the file and the line numbers may be different but the process should still be the same.

In the file “app/design/frontend/defualt/modern/layout/catalog.xml” (around line 256) find the following line and remove/comment it out:

<reference name="right">
  
<block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>

</reference>

Remove or comment out like this:

<!–– 
<block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
 ––>

Change the following to include the above at around line 250 as shown in green below:

<block type="core/template_facade" name="product.info.container2" as="container2">

  <action method="setDataByKey"><key>alias_in_layout</key><value>container2
</value>
</action>

  <action method="setDataByKeyFromRegistry"><key>options_container</key>
<key_in_registry>product</key_in_registry></action>
  <action method="append"><block>product.info.options.wrapper</block></action>

  <action method="append"><block>product.info.options.wrapper.bottom</block>
</action>

</block>

  <action method="unsetCallChild"><child>container1</child><call>ifEquals</call>
<if>0</if><key>alias_in_layout</key><key>options_container</key></action>
  <action method="unsetCallChild"><child>container2</child><call>ifEquals</call>
<if>0</if><key>alias_in_layout</key><key>options_container</key></action>

</block>

  <block type="catalog/product_list_related" name="catalog.product.related" after="-" template="catalog/product/list/related.phtml"/>

</reference>

If you save this you will see it now appears at top of the middle container, even thought the code is at the end. We need to change before="-" to after="-" in the code to place it at the bottom.

This code was found on a Magento forum. The credit goes to Dx3webs and the original article can be found here.

Addendum 03/02/2011: I came across a problem with the related products not showing up when using this method on another site. To fix the problem, go to Admin > System > Index Management.  All the indexes show green icons that say their status is “ready”, this might not be true. Select all and re-index, and your related products should now show up.

This article was posted on 9 July 2010 in Magento, Tutorials

comments

What you have had to say about all this...

<nitpick>

<–– 
<block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
 ––

Should be

<!–– 
<block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
 ––

</nitpick>

- Matt Alexander

I found this solution buried in a Magento forum so decided to put it into a post on my site so I could easily find it in the future. Looks like whoever posted that copied it word for word from your site. I will add a link back to your original post within the article.

@Matt
Well spotted, I have updated the code in the article.

- markinns

Thanks,
Much appreciated.

- Dx3webs

I thank you humbly for sharing your wisdom JJWY

- Jalen

Thanks for the post. I have tried looking for how to display page elements on the product view.phml based on conditional statements. Specifically, check if related products exist, then echo… if not then echo something else. Any thoughts?

- Robert

Thanks for write up Magento bit. It’s very meaningful tutorial so long. Here all impression really touching indeed. I enjoyed this crucial info. Keep it up though!

- Denim

That's the end of this article. I hope you found it useful. If you're enjoyed this article why don't you have a look around the archives, where you can find some more tutorials, tips and general ramblings.