我有一个产品系列,我从一个可配置的产品中获得,我想过滤该系列只包括附有图像的产品。我该怎么做?
代码看起来像这样:
$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 ) {
...
}
感谢任何帮助。谢谢! 乔
答案 0 :(得分:5)
$this->_productCollection->addAttributeToFilter('small_image',array('notnull'=>'','neq'=>'no_selection'))
答案 1 :(得分:0)
也适用于此:
$collection->addAttributeToFilter('small_image',array('notnull'=>'','neq'=>'no_selection'));