Thursday 5 June 2014

Magento get related products by product id

Magento displays related products block in product page default. If u would like to display this block in other page, u need to customize this block.


<?php
  
//load a product resources
$_product = Mage::getModel('catalog/product')->load($productId);
  
//save the product into the registry
Mage::register('product', $_product);
  
//call $_product's related products
echo $this->getLayout()->createBlock('catalog/product_list_related')->setTemplate('catalog/product/list/related.phtml')->toHtml();
  
?>

1 comment:

  1. Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home. gaming chair under 200

    ReplyDelete