Php 为具有图像的产品筛选Magento产品集合

Php 为具有图像的产品筛选Magento产品集合,php,collections,magento,Php,Collections,Magento,我有一个从可配置产品中获取的产品集合,我希望过滤该集合,使其仅包括附加了图像的产品。我该怎么办 代码如下所示: $configurableProduct = $this->getConfigurableProduct(); $childProducts = $configurableProduct->getTypeInstance()->getUsedProductCollection(); // add some filter here to get only produc

我有一个从可配置产品中获取的产品集合,我希望过滤该集合,使其仅包括附加了图像的产品。我该怎么办

代码如下所示:

$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 ) {
   ...
}
感谢您的帮助。谢谢 Joe也可以处理以下问题:

$collection->addAttributeToFilter('small_image',array('notnull'=>'','neq'=>'no_selection'));

谢谢你的回答,科伊尔。我希望获得基于“gallery”表集的图像,因为我不能保证用户已选择图像作为“small_image”的默认图像。
$collection->addAttributeToFilter('small_image',array('notnull'=>'','neq'=>'no_selection'));