I am trying to do the same thing in Magento CE 220.127.116.11 . Basically I want to edit the related products block to show all products that have the same value for a specific attribute. Basically I have an attribute called family and when you view product abc which belongs to the attribute family 'Pepsi' I want to display all other products that have a value for the family attribute of 'pepsi'
So I am altering the file app/design/frontend/MY_THEME/default/template/catalog/product/list/related.phtml
The first thing I do in this file is get the value of the family attribute by doing the below
//get the name of the family that the product being viewed is a part of $itemcollectionname = Mage::getModel('catalog/product')->load($_product->getId())->getAttributeText('family');
I then tried using the code in the above post like so
$rcollection = Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()) //add some attribtues to select ->addAttributeToFilter('family', array('eq'=>$itemcollectionname);//filter products with the same family Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($rcollection); //only active products Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($rcollection);//only visible products $rcollection->setPage(1,5);//limit to 5 products echo "$rcollection<br />";