0

I want to exclude product who has specific attributes in category product listing page.

I have created one attribute product_disble_listing. if product_disble_listing set yes to product that product not show in listing page. override below block in custom module.

Magento\Catalog\Block\Product\ListProduct  

and I have added below code in custom module.

$this->_productCollection->addAttributeToFilter('product_disble_listing', array('neq' => 1));

product collection show correctly but product count, pagination, price filter, color attributes are showing wrong data.

0

I have resolved it. I have added just below code.

$this->_productCollection->addAttributeToFilter('product_disble_listing', array('neq' => 1));
$this->_productCollection->getSize();


return $this->_productCollection;

And data showing correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.