本文整理汇总了PHP中Magento\Framework\Model\Resource\Db\Collection\AbstractCollection::addFieldToFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractCollection::addFieldToFilter方法的具体用法?PHP AbstractCollection::addFieldToFilter怎么用?PHP AbstractCollection::addFieldToFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\Resource\Db\Collection\AbstractCollection
的用法示例。
在下文中一共展示了AbstractCollection::addFieldToFilter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFieldToFilter
/**
* Add field filter to collection
* If $attribute is an array will add OR condition with following format:
* array(
* array('attribute'=>'firstname', 'like'=>'test%'),
* array('attribute'=>'lastname', 'like'=>'test%'),
* )
*
* @param string $field
* @param null|string|array $condition
* @return \Magento\Eav\Model\Entity\Collection\AbstractCollection
*
* @see self::_getConditionSql for $condition
*/
public function addFieldToFilter($field, $condition = null)
{
if (isset($this->_fields[$field])) {
$field = $this->_fields[$field];
}
return parent::addFieldToFilter($field, $condition);
}
示例2: addFieldToFilter
/**
* Checks if field is 'subscribers_total', 'subscribers_sent'
* to add specific filter or adds reguler filter
*
* @param string $field
* @param null|string|array $condition
* @return $this
*/
public function addFieldToFilter($field, $condition = null)
{
if (in_array($field, ['subscribers_total', 'subscribers_sent'])) {
$this->addFieldToFilter('main_table.queue_id', ['in' => $this->_getIdsFromLink($field, $condition)]);
return $this;
} else {
return parent::addFieldToFilter($field, $condition);
}
}
示例3: addFieldToFilter
/**
* Provide support for website id filter
*
* @param string $field
* @param null|string|array $condition
* @return $this
*/
public function addFieldToFilter($field, $condition = null)
{
if ($field == 'website_ids') {
return $this->addWebsiteFilter($condition);
}
parent::addFieldToFilter($field, $condition);
return $this;
}
示例4: addFieldToFilter
/**
* Add field filter to collection
*
* @param string $field
* @param null|string|array $condition
* @return $this
* @see self::_getConditionSql for $condition
*/
public function addFieldToFilter($field, $condition = null)
{
if ($field == 'name') {
$conditionSql = $this->_getConditionSql($this->getConnection()->getIfNullSql('p.value', 'p_d.value'), $condition);
$this->getSelect()->where($conditionSql, null, \Magento\Framework\DB\Select::TYPE_CONDITION);
return $this;
} else {
return parent::addFieldToFilter($field, $condition);
}
}
示例5: addFieldToFilter
/**
* Filter by customer ID, as 'type' field does not exist
*
* @param string $fieldName
* @param array $condition
* @return $this
*/
public function addFieldToFilter($fieldName, $condition = null)
{
if ($fieldName == 'type' && is_array($condition) && isset($condition['eq'])) {
$fieldName = 'customer_id';
if ($condition['eq'] === \Magento\Customer\Model\Visitor::VISITOR_TYPE_VISITOR) {
$condition = ['null' => 1];
} else {
$condition = ['moreq' => 1];
}
}
return parent::addFieldToFilter($this->_getFieldMap($fieldName), $condition);
}
示例6: addFieldToFilter
/**
* @param string|array $field
* @param string|int|array|null $condition
* @return \Magento\Cms\Model\Resource\Block\Collection
*/
public function addFieldToFilter($field, $condition = null)
{
return parent::addFieldToFilter($field, $condition);
}