本文整理汇总了PHP中Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection::addFieldToFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractCollection::addFieldToFilter方法的具体用法?PHP AbstractCollection::addFieldToFilter怎么用?PHP AbstractCollection::addFieldToFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
的用法示例。
在下文中一共展示了AbstractCollection::addFieldToFilter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFieldToFilter
/**
* Add field filter to collection
*
* @param string|array $field
* @param null|string|array $condition
* @return $this
*/
public function addFieldToFilter($field, $condition = null)
{
if ($field === 'store_id') {
return $this->addStoreFilter($condition, false);
}
return parent::addFieldToFilter($field, $condition);
}
示例2: addFieldToFilter
/**
* @inheritdoc
*/
public function addFieldToFilter($field, $condition = null)
{
if (in_array($field, ['created_at', 'updated_at'], true)) {
$field = 'main_table.' . $field;
}
return parent::addFieldToFilter($field, $condition);
}
示例3: addFieldToFilter
/**
* Multi store view.
*
* @param string|array $field
* @param null|string|array $condition
*/
public function addFieldToFilter($field, $condition = null)
{
$attributes = array('name', 'status', 'click_url', 'target', 'image_alt', 'maintable');
$storeViewId = $this->getStoreViewId();
if (in_array($field, $attributes) && $storeViewId) {
if (!in_array($field, $this->_addedTable)) {
$sql = sprintf('main_table.banner_id = %s.banner_id AND %s.store_id = %s AND %s.attribute_code = %s ', $this->getConnection()->quoteTableAs($field), $this->getConnection()->quoteTableAs($field), $this->getConnection()->quote($storeViewId), $this->getConnection()->quoteTableAs($field), $this->getConnection()->quote($field));
$this->getSelect()->joinLeft(array($field => $this->getTable('magestore_bannerslider_value')), $sql, array());
$this->_addedTable[] = $field;
}
$fieldNullCondition = $this->_translateCondition("{$field}.value", ['null' => TRUE]);
$mainfieldCondition = $this->_translateCondition("main_table.{$field}", $condition);
$fieldCondition = $this->_translateCondition("{$field}.value", $condition);
$condition = $this->_implodeCondition($this->_implodeCondition($fieldNullCondition, $mainfieldCondition, \Zend_Db_Select::SQL_AND), $fieldCondition, \Zend_Db_Select::SQL_OR);
$this->_select->where($condition, NULL, \Magento\Framework\DB\Select::TYPE_CONDITION);
return $this;
}
if ($field == 'store_id') {
$field = 'main_table.banner_id';
}
return parent::addFieldToFilter($field, $condition);
}
示例4: 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;
}
示例5: 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);
}
}