Magento Load Related, Upsell and crosssell Products by Ajax using dynamic block creation

To load related products using Ajax just pass current product id by Ajax request and create a controller and add the following code to load the related products:

[box] //Register the Current Magento Product
Mage::register(‘product’, Mage::getModel(‘catalog/product’)->load($productId));
$block = Mage::app()->getLayout()->createBlock(‘catalog/product_list_related’)->setTemplate(‘catalog/product/list/related.phtml’);
$message .= $block->toHTml();
return $message;[/box]

You Might Also Like