Bob van Luijt
Bob van Luijt

Reputation: 7588

Magento: how to use catalogsearch/query model to find products without images?

This is my code:

$catalogSearchModel = Mage::getModel('catalogsearch/query')->setQueryText($q);
$catalogSearchModelCollection = $catalogSearchModel->getResultCollection();
$catalogSearchModelCollection->getSelect()->limit(5);
$results = $catalogSearchModelCollection->getData();

What should I add to this to only find products with images?

Upvotes: 0

Views: 930

Answers (1)

Shyam Ranpara
Shyam Ranpara

Reputation: 624

Use following code for product which have images.

$catalogSearchModel = Mage::getModel('catalogsearch/query')->setQueryText($q);
 $catalogSearchModelCollection = $catalogSearchModel->getResultCollection();
 $catalogSearchModelCollection->addAttributeToFilter('image', array('neq' => 'no_selection');
 $catalogSearchModelCollection->getSelect()->limit(5);
 $results = $catalogSearchModelCollection->getData();

Upvotes: 2

Related Questions