Magento:如何使用catalogsearch / query模型查找没有图像的产品?

时间:2015-03-26 21:05:33

标签: magento search

这是我的代码:

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

我应该添加什么才能找到带图像的产品?

1 个答案:

答案 0 :(得分:2)

对具有图像的产品使用以下代码。

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