views:

336

answers:

1

I have a product collection that I am getting from a configurable product, and I want to filter that collection to only include products that have images attached to them. How do I go about this?

Code looks something like this:

$configurableProduct = $this->getConfigurableProduct();
$childProducts = $configurableProduct->getTypeInstance()->getUsedProductCollection();

// add some filter here to get only products with images
$childProducts->addAttributeToFilter( /* what goes here? */ );    

foreach( $childProducts as $product ) {
   ...
}

Any help is appreciated. Thanks! Joe

A: 

$this->_productCollection->addAttributeToFilter('small_image',array('notnull'=>'','neq'=>'no_selection'))

coylOne
Thanks for the answer, coyl. I'm hoping to get images based on the "gallery" set of tables, since I can't guarantee that the user has selected an image as default for "small_image".
Joseph Mastey