Magento 2 : Condition Type in Search Filter

Today we are going to keep it just short and sweet to help our Magento 2 developers to find out what all condition types are available in Magento 2 -:

“eq” => EqualValue

“neq” => notEqualValue

“like” => likeValue

“nlike” => notLikeValue

“is” => isValue

“in” => inValues

“nin” => notInValues

“notnull” => valueIsNotNull

“null” => valueIsNull

“moreq” => moreOrEqualValue

“gt” => greaterValue

“lt” => lessValue

“gteq” => greaterOrEqualValue

“lteq” => lessOrEqualValue

“finset” => valueInSet

“from” => fromValue

“to” => toValue

Quick example to extract order data with the help of Magento 2 using filter builder, search criterial builder and condition types

$eqFilter = $this->filterBuilder
$statusFilter = $this->filterBuilder
filterBuilder – \Magento\Framework\Api\FilterBuilder $filterBuilder

$searchCriteria = $this->searchCriteriaBuilder
            ->addFilters([$eqFilter, $statusFilter])
searchCriteriaBuilder – \Magento\Framework\Api\SearchCriteriaBuilder

$orders = $this->orderRepository->getList($searchCriteria);
orderRepository – \Magento\Sales\Api\OrderRepositoryInterface $orderRepository

That’s it, Hope this article helped you in some way. Please leave us your comment and let us know what do you think? Thanks.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.