当前位置: 首页>>代码示例>>PHP>>正文


PHP Collection::addFieldToFilter方法代码示例

本文整理汇总了PHP中Magento\Catalog\Model\Resource\Product\Collection::addFieldToFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::addFieldToFilter方法的具体用法?PHP Collection::addFieldToFilter怎么用?PHP Collection::addFieldToFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Catalog\Model\Resource\Product\Collection的用法示例。


在下文中一共展示了Collection::addFieldToFilter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: tearDown

 /**
  * Execute per test cleanup
  */
 public function tearDown()
 {
     /** @var \Magento\Framework\Registry $registry */
     $registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\Registry');
     $registry->unregister('isSecureArea');
     $registry->register('isSecureArea', true);
     $this->productCollection->addFieldToFilter('entity_id', ['in' => [10, 11, 12]])->delete();
     unset($this->productCollection);
     $registry->unregister('isSecureArea');
     $registry->register('isSecureArea', false);
 }
开发者ID:opexsw,项目名称:magento2,代码行数:14,代码来源:StockItemTest.php

示例2: addFieldToFilter

 /**
  * Add filtering
  *
  * @param string $field
  * @param null|string $condition
  * @return $this
  */
 public function addFieldToFilter($field, $condition = null)
 {
     if ($field == 'link_title') {
         $conditionSql = $this->_getConditionSql('l.title', $condition);
         $this->getSelect()->where($conditionSql);
     } else {
         parent::addFieldToFilter($field, $condition);
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:Collection.php

示例3: addFilterGroupToCollection

 /**
  * Helper function that adds a FilterGroup to the collection.
  *
  * @param FilterGroup $filterGroup
  * @param Collection $collection
  * @return void
  * @throws \Magento\Framework\Exception\InputException
  */
 protected function addFilterGroupToCollection(FilterGroup $filterGroup, Collection $collection)
 {
     $fields = [];
     foreach ($filterGroup->getFilters() as $filter) {
         $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
         $field = $this->translateField($filter->getField());
         $fields[] = array('attribute' => $field, $condition => $filter->getValue());
     }
     if ($fields) {
         $collection->addFieldToFilter($fields);
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:20,代码来源:ProductService.php

示例4: addFilterGroupToCollection

 /**
  * Helper function that adds a FilterGroup to the collection.
  *
  * @param \Magento\Framework\Api\Search\FilterGroup $filterGroup
  * @param Collection $collection
  * @return void
  */
 protected function addFilterGroupToCollection(\Magento\Framework\Api\Search\FilterGroup $filterGroup, Collection $collection)
 {
     $fields = [];
     foreach ($filterGroup->getFilters() as $filter) {
         $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
         $fields[] = ['attribute' => $filter->getField(), $condition => $filter->getValue()];
     }
     if ($fields) {
         $collection->addFieldToFilter($fields);
     }
 }
开发者ID:opexsw,项目名称:magento2,代码行数:18,代码来源:ProductRepository.php

示例5: _renderFiltersBefore

 /**
  * @inheritdoc
  */
 protected function _renderFiltersBefore()
 {
     $this->requestBuilder->bindDimension('scope', $this->getStoreId());
     if ($this->queryText) {
         $this->requestBuilder->bind('search_term', $this->queryText);
     }
     $priceRangeCalculation = $this->_scopeConfig->getValue(\Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory::XML_PATH_RANGE_CALCULATION, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     if ($priceRangeCalculation) {
         $this->requestBuilder->bind('price_dynamic_algorithm', $priceRangeCalculation);
     }
     $this->requestBuilder->setRequestName('quick_search_container');
     $queryRequest = $this->requestBuilder->create();
     $this->queryResponse = $this->searchEngine->search($queryRequest);
     $ids = [0];
     /** @var \Magento\Framework\Search\Document $document */
     foreach ($this->queryResponse as $document) {
         $ids[] = $document->getId();
     }
     parent::addFieldToFilter('entity_id', ['in' => $ids]);
     $this->_totalRecords = count($ids) - 1;
     if ($this->order && $this->order['field'] == 'relevance') {
         $this->getSelect()->order(new \Zend_Db_Expr($this->_conn->quoteInto('FIELD(e.entity_id, ?) ' . $this->order['dir'], $ids)));
     }
     return parent::_renderFiltersBefore();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:28,代码来源:Collection.php


注:本文中的Magento\Catalog\Model\Resource\Product\Collection::addFieldToFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。