Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter Magento Product Collection for Products with Images

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

like image 817
Joe Mastey Avatar asked Jan 12 '10 19:01

Joe Mastey


1 Answers

$this->_productCollection->addAttributeToFilter('small_image',array('notnull'=>'','neq'=>'no_selection'))
like image 99
coylOne Avatar answered Nov 09 '22 04:11

coylOne