Popular Posts

Saturday, 4 March 2017

Magento: Get all related products of current product

Many other situations can be there, when we may not have option, but to write custom code to get related products of currently loaded product.

For such situations, try this code:

$collection = Mage::getModel('catalog/product_link')
                    ->getCollection()
                    ->addFieldToFilter('product_id',$product_id)
                    ->addFieldToFilter('link_type_id','1');

$related_products = $collection->getData();


This will give you list of all related products of a product.

Note: Here $product_id is the id of currently loaded product.

1 comment:

Magento: How to get last order id

There are many ways to get last order id:   1. From checkout session: $lastOrderId = Mage::getSingleton('checkout/session'...