I'm working on a website where I'm using Magento 1.7. I want to display the related product of the current product on product view page. I tried many links like these, but none of them worked for me. Please help me on this. I'm newbie to magento.
Magento – Showing related products in product view page
magento-1.7productproduct-linking
Best Answer
This is built in to most themes and all of the base themes. So I'm guessing what you want is to relocate the related products to another area.
This is possible in a few different ways:
Via layouts
Using layout XML you can provide the following block declaration to any
<reference>
-This should call and render the block and associated template file.
Roll your own
Why not? You're a capable developer! In this case, you can do something very similar to what you posted in the links above. This particular example is fairly trivial but shows you what may be possible:
Edit
My what a difference a year makes. Don't load models in loops. Bad Phillip, BAD.
This can be placed anywhere on the product page or
view.phtml
but best practice dictates that you should place this in a Block method and reference that inside the template. Bottom line, you either need to have $_product available or useMage::registry('current_product')
.