Magento 2中允许的条件类型是什么?


19

在Magento 2中将过滤器添加到搜索条件时,允许的条件类型的列表是什么?

有关Internet使用eq条件类型中搜索条件的所有示例。还有其他吗?您在某处有完整的清单吗?

编辑1:请看下面的代码块。我对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);

Answers:


45

可用条件

 "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

2
这是有关搜索条件的官方文档,还显示了可用条件。devdocs.magento.com/guides/v2.1/howdoi/webapi/...
Bunyamin伊南

上面评论中的Devdocs页面不再有效,请检查devdocs.magento.com/guides/v2.3/rest/performing-searches.html中可用的类型。
吉塞

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.