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 ->setField('custom_attribute') ->setValue(1) ->setConditionType('eq') ->create();
$statusFilter = $this->filterBuilder ->setField('status') ->setValue(array('pending','processing')) ->setConditionType('in') ->create();
filterBuilder – MagentoFrameworkApiFilterBuilder $filterBuilder
$searchCriteria = $this->searchCriteriaBuilder ->addFilters([$eqFilter, $statusFilter]) ->create();
searchCriteriaBuilder – MagentoFrameworkApiSearchCriteriaBuilder
$orders = $this->orderRepository->getList($searchCriteria);
orderRepository – MagentoSalesApiOrderRepositoryInterface $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.