I am passing attribute color value in URL as rest/V1/filterattribute/81?color=32,5.
By using getparams

$bodyParams = $this->request->getParams();
foreach($bodyParams as $key=>$value)
$this->collection->addFieldToFilter($key,['in' => array($value)]);

$this->collection->addFieldToFilter($key,['in' => 32,5]);

By giving value directly it works. But giving value by variable it did not work.

What I am doing wrong? How to pass multiple values in addFieldToFilter?


  • Try removing "array" as in your working example you define an int, while in the nonworking you have an array($value). – Petar Borisovski Nov 24 '20 at 12:39

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.