0

In Magento 2.3 I need to filter the collection as per below scenario. I have L, W and H attributes for products And user input is "X, Y and Z" then the following condition will give the desired productis in filter result:

(L >= X) AND (W >= Y) AND (H >= Z)

OR

(L >= X) AND (H >= Y) AND (W >= Z)

OR

(W >= X) AND (L >= Y) AND (H >= Z)

OR

(W >= X) AND (H >= Y) AND (L >= Z)

OR

(H >= X) AND (W >= Y) AND (L >= Z)

OR

(H >= X) AND (L >= Y) AND (W >= Z)

I can achieve only one of the condition by the following

$productCollection
->addAttributeToFilter('L', array('gte' => X))
->addAttributeToFilter('H', array('gte' => Y))
->addAttributeToFilter('W', array('gte' => Z))

But now I also want to add the other 5 conditions with OR condition to the above collection.

How to achieve this?

Your Answer

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

Browse other questions tagged or ask your own question.