Magento -> How can I list products with same multiple select attribute?

jeaniguana

New Member
I'm trying to retrieve products that carry same attribute. Specifically multiple select type. It seems the basic methods don't work. Selecting only the "name" attribute, I get all my products listed. When I try to filter "shop_by_color", it filters down, but not entirely. Not sure why it removes some and leaves others, even though they are the wrong ones. Any tips appreciated.\[code\]<?php $model = Mage::getModel('catalog/product');$collection = $model->getCollection();$collection->addAttributeToSelect('name');$collection->addAttributeToFilter('shop_by_color'); // multiple select attribute$collection->addFieldToFilter(array(array('attribute'=>'shop_by_color','finset'=>array('Yellow, White'),)));$collection->load();?><ul><?php foreach($collection as $product) : ?><li><a href="http://stackoverflow.com/questions/1997200/<?php echo $product->getProductUrl() ?>"><?php echo $product->getName() ?></a></li> <?php endforeach; ?> </ul>\[/code\]
 
Back
Top