Is there a way to hide products that have the price at 0?

I tried with this Plugin but it shows the same all the products even those at price 0.


namespace Vendor\Namespace\Plugin;

use Magento\Catalog\Block\Product\ListProduct;
use Magento\Eav\Model\Entity\Collection\AbstractCollection;
use Magento\Framework\Exception\LocalizedException;

 * Class ListProductPlugin
class ListProductPlugin

     * @param ListProduct $subject
     * @param AbstractCollection $resultCollection
     * @return AbstractCollection
     * @throws LocalizedException
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
    public function afterGetLoadedProductCollection(
        ListProduct $subject,
        AbstractCollection $resultCollection
    ) {
        $resultCollection->addAttributeToFilter('price', ['gt' => 0]);

        return $resultCollection;

Could anyone point me to the right direction?


1 Answer 1


Try using eq like below code

$resultCollection->addAttributeToFilter('price', ['eq' => 0]);

Hope it Helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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