Skip to content

Magento 2 How to filter product collection base on Product Attribute Rule

https://i.imgur.com/rW2R7qK.png

I have created a Product Attribute rule as per the above image now set below the product attribute option for filter products in stock.

https://i.imgur.com/m1i77Ps.png

But when product collection is fetched display all products in stock as well as out of stock.

How to filter product collection based on this set rule?