I want to apply multiple price ranges on final price of product collection. I have tried below code.

->where('price_index.final_price <= ' . $maxprice)- 
>where('price_index.final_price >= ' . $minprice);

But from above method i can only apply one range to it. Also price range is dynamic. It can be one or more than one. I found following solution regarding my problem


But addFieldToFilter is not working on $collection. Any help will be appreciated.

1 Answer 1


You can pass more complex conditions to the where() method and there is also a orWhere method which appends the condition with OR.

For example this should do what you expect:

->where(diy_kit_price >= 0 AND diy_kit_price <= 5000) 
->orWhere(diy_kit_price >= 15000 AND diy_kit_price <= 20000);
  • Thanks it helped! There is just little problem as i mentioned price ranges are dynamic that's why when i am going through ranges in a loop i have to check if it's a first iteration than use ->where else ->orWhere. Which feels odd to me. Feb 13, 2019 at 7:08

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.