I am using Magento 2.2.2

I have created one attribute "Retail Price". Input type for this attribute is "Price". I have added values in some products for this attribute. Now I want to load product collection based on "Retail Price" range. I have tried using the following code:

$collection = $productCollection->addAttributeToSelect('*')
                ->addAttributeToFilter('status', 1)
                ->addAttributeToFilter('retail_price' , array('from' => 501, 'to' => 700));

After using the above code I didn't get any products in the result. So, what can be the issue in the above code?

1 Answer 1


Try This :-

$collection = $productCollection->addAttributeToSelect('*')
                ->addAttributeToFilter('status', 1)
                ->addFieldToFilter('retail_price', array('gteq' => 501))
                ->addFieldToFilter('retail_price', array('lteq' => 700));
  • I have implemented your solution but it's not working. Is there any alternate solution for this? May 21, 2019 at 10:30
  • any error ????? May 21, 2019 at 10:33
  • check updated answer May 21, 2019 at 10:36
  • how can I apply greater or equal(>=)/ less or equal(<=) instead of only 'gt' and 'lt'? May 22, 2019 at 11:06
  • check my updated answer May 22, 2019 at 12:04

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.