In Magento 2, yourModule/etc/di.xml
<type name="Magento\Catalog\Model\Layer">
<plugin name="exclude_no_image_product" type="yourCompany\yourModule\Model\Rewrite\LayerPlugin"/>
</type>
Add file yourCompany\yourModule\Model\Rewrite\LayerPlugin.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace yourCompany\yourModule\Model\Rewrite;
/**
* Catalog view layer model
*
* @api
* @SuppressWarnings(PHPMD.LongVariable)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
*/
class LayerPlugin
{
/**
* Retrieve current layer product collection
*
* @return \Magento\Catalog\Model\ResourceModel\Product\Collection
*/
public function aroundgetProductCollection(\Magento\Catalog\Model\Layer $subject, \Closure $proceed)
{
$collection = $proceed();
$collection
->addAttributeToSelect('*')
->addAttributeToFilter('small_image', array('neq' => 'no_selection'))
->addAttributeToFilter('small_image', array('neq' => ''))
->addAttributeToFilter('small_image', array('neq' => null));
return $collection;
}
}
It will work. I have found and i am using in my website. Learn more.. www.webizon.in