public function getWhereFromApiCriteria(\Magento\Framework\Api\Search\SearchCriteriaInterface $criteria, \Praxigento\Core\Repo\Query\Criteria\IMapper $mapper = null) { $result = ''; $filterGroups = $criteria->getFilterGroups(); foreach ($filterGroups as $filterGroup) { $processed = []; // I don't know what is it "filter group" so uniquelize conditions inside one group only /** @var \Magento\Framework\Api\Filter $item */ foreach ($filterGroup->getFilters() as $item) { $field = $item->getField(); if ($mapper) { $field = $mapper->get($field); } $cond = $item->getConditionType(); $value = $item->getValue(); $where = $this->_conn->prepareSqlCondition($field, [$cond => $value]); if (!in_array($where, $processed)) { $result .= "({$where}) AND "; $processed[] = $where; } } } $result .= '1'; return $result; }