How to show related product any where in magento

1. Copy and paste this code in your template page.

<!--- Code Start from here   -->

<div class="related_product"><?php $related_prods = $_product->getRelatedProductIds();foreach($related_prods as $related){   $_item = Mage::getModel('catalog/product')->load($related);    //echo $_rel->getName() . " " . $_rel->getSku();  ?> <div class="product-show"> <a href="<?php echo $_item->getProductUrl(); ?>" title="<?php echo $this->escapeHtml($_item->getName()); ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(50); ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($_item->getName()); ?>" /></a> <div class="product-details">     <p class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></p>       <?php echo $this->getPriceHtml($_item, true, '-related') ?>    <?php if ($this->helper('wishlist')->isAllow()) : ?>       <a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a>    <?php endif; ?> </div> </div> <?php?></div>

<!--- Code end  here   --> 

No comments:

Post a Comment