14

What is the list of allowed condition types while adding filter to search criteria in Magento 2?

All of the examples about search criteria in the internet use eq condition type. Is there any other? Do you have a complete list somewhere?

EDIT 1: Please look at the following code block. What are my options for condition_type?

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
$productRepository = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);

/** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = $objectManager->get(\Magento\Framework\Api\SearchCriteriaBuilder::class);

/** @var \Magento\Framework\Api\FilterBuilder $filterBuilder */
$filterBuilder = $objectManager->get(\Magento\Framework\Api\FilterBuilder::class);
$filterSpecialPrice = $filterBuilder->setField('special_price')
    ->setValue('0')
    ->setConditionType('eq')
    ->create();

$searchCriteria = $searchCriteriaBuilder->addFilter($filterSpecialPrice)
    ->create();

$productCollection = $productRepository->getList($searchCriteria);
30

available conditions

 "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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.