in magento how can i Get related product in the product listing page

Sourav picture Sourav · Sep 17, 2011 · Viewed 19.9k times · Source

I am doing a magento project where i have to bring related product and upsell product in the product listing page which is product/list.phtml i can get all the product details from
foreach ($_productCollection as $_product): $_product->

but i can't get any related product and upsell product using $_product->
please help me please

Answer

Kenny picture Kenny · Sep 21, 2011

You can do the following (inside the foreach loop)

$related_product_collection = $_product->getRelatedProductCollection();
$related_product_collection->AddStoreFilter();

Regards, Kenny

PS: If you want to know which methods are available, you can always run the

var_dump(get_class_methods($_product)); die;
//or
Mage::log(print_r(get_class_methods($_product),true));

First one will print all available methods on the screen while second one will output it in the system.log located in the /var/log/system.log (make sure that in configuration->developer you have logging enabled of course)