Show Magento Related Products Regardless

A quick micro-blog today about something which came up for the first time today – how to make related products show up regardless of whether you have them in your cart or not.

I was using the related products collection to create a custom add-to-cart form, which allows you to add multiple products to your cart at once. However, having done that once the related products vanished because they’re programmed to disappear once they’re in your cart.

I created a new block type extending the Mage_Catalog_Block_Product_List_Related class. In the method called _prepareData() you just need to comment out or delete this bit of code:

Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($this->_itemCollection,
	Mage::getSingleton('checkout/session')->getQuoteId()
);

Now just update your block type and that’s all there is to it!