Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Collection Class Reference
Inheritance diagram for Collection:
Collection AbstractCollection AbstractCollection AbstractDb SourceProviderInterface Collection ArrayInterface CollectionDataSourceInterface OptionSourceInterface ArgumentInterface

Public Member Functions

 __construct (\Magento\Framework\Data\Collection\EntityFactory $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\App\ResourceConnection $resource, \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\ResourceModel\Url $catalogUrl, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Customer\Api\GroupManagementInterface $groupManagement, \Magento\Search\Model\QueryFactory $catalogSearchData, \Magento\Framework\Search\Request\Builder $requestBuilder, \Magento\Search\Model\SearchEngine $searchEngine, \Magento\Framework\Search\Adapter\Mysql\TemporaryStorageFactory $temporaryStorageFactory, \Magento\Framework\DB\Adapter\AdapterInterface $connection=null, $searchRequestName='catalog_view_container', SearchResultFactory $searchResultFactory=null, ProductLimitationFactory $productLimitationFactory=null, MetadataPool $metadataPool=null)
 
 setSearch (\Magento\Search\Api\SearchInterface $object)
 
 setSearchCriteriaBuilder (\Magento\Framework\Api\Search\SearchCriteriaBuilder $object)
 
 setFilterBuilder (\Magento\Framework\Api\FilterBuilder $object)
 
 addFieldToFilter ($field, $condition=null)
 
 addSearchFilter ($query)
 
 setOrder ($attribute, $dir=Select::SQL_DESC)
 
 setGeneralDefaultQuery ()
 
 getFacetedData ($field)
 
 addCategoryFilter (\Magento\Catalog\Model\Category $category)
 
 setVisibility ($visibility)
 
- Public Member Functions inherited from Collection
 __construct (\Magento\Framework\Data\Collection\EntityFactory $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\App\ResourceConnection $resource, \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\ResourceModel\Url $catalogUrl, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Stdlib\DateTime $dateTime, GroupManagementInterface $groupManagement, \Magento\Framework\DB\Adapter\AdapterInterface $connection=null, ProductLimitationFactory $productLimitationFactory=null, MetadataPool $metadataPool=null, TableMaintainer $tableMaintainer=null, PriceTableResolver $priceTableResolver=null, DimensionFactory $dimensionFactory=null)
 
 getCatalogPreparedSelect ()
 
 getPriceExpression ($select)
 
 getAdditionalPriceExpression ($select)
 
 getCurrencyRate ()
 
 getFlatState ()
 
 isEnabledFlat ()
 
 getNewEmptyItem ()
 
 setEntity ($entity)
 
 setStore ($store)
 
 _loadAttributes ($printQuery=false, $logQuery=false)
 
 addAttributeToSelect ($attribute, $joinType=false)
 
 addIdFilter ($productId, $exclude=false)
 
 addWebsiteNamesToResult ()
 
 load ($printQuery=false, $logQuery=false)
 
 addStoreFilter ($store=null)
 
 addWebsiteFilter ($websites=null)
 
 getLimitationFilters ()
 
 addCategoryFilter (\Magento\Catalog\Model\Category $category)
 
 addCategoriesFilter (array $categoriesFilter)
 
 joinMinimalPrice ()
 
 getMaxAttributeValue ($attribute)
 
 getAttributeValueCountByRange ($attribute, $range)
 
 getAttributeValueCount ($attribute)
 
 getSelectCountSql ()
 
 getAllIds ($limit=null, $offset=null)
 
 getProductCountSelect ()
 
 unsProductCountSelect ()
 
 addCountToCategories ($categoryCollection)
 
 joinUrlRewrite ()
 
 addUrlRewrite ($categoryId='')
 
 addMinimalPrice ()
 
 addFinalPrice ()
 
 getAllIdsCache ($resetCache=false)
 
 setAllIdsCache ($value)
 
 addPriceData ($customerGroupId=null, $websiteId=null)
 
 addAttributeToFilter ($attribute, $condition=null, $joinType='inner')
 
 addTaxPercents ()
 
 requireTaxPercent ()
 
 addOptionsToResult ()
 
 addFilterByRequiredOptions ()
 
 setVisibility ($visibility)
 
 addAttributeToSort ($attribute, $dir=self::SORT_ORDER_ASC)
 
 applyFrontendPriceLimitations ()
 
 addCategoryIds ()
 
 addTierPriceData ()
 
 addTierPriceDataByGroupId ($customerGroupId)
 
 addPriceDataFieldFilter ($comparisonFormat, $fields)
 
 addMediaGalleryData ()
 
 getProductEntityMetadata ()
 
 clear ()
 
 setOrder ($attribute, $dir=Select::SQL_DESC)
 
 getMaxPrice ()
 
 getMinPrice ()
 
 getPriceStandardDeviation ()
 
 getPricesCount ()
 
- Public Member Functions inherited from AbstractCollection
 __construct (\Magento\Framework\Data\Collection\EntityFactory $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\App\ResourceConnection $resource, \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Eav\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\DB\Adapter\AdapterInterface $connection=null)
 
 setStore ($store)
 
 setStoreId ($storeId)
 
 getStoreId ()
 
 getDefaultStoreId ()
 
- Public Member Functions inherited from AbstractCollection
 __construct (\Magento\Framework\Data\Collection\EntityFactory $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\App\ResourceConnection $resource, \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Eav\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\DB\Adapter\AdapterInterface $connection=null)
 
 getTable ($table)
 
 setEntity ($entity)
 
 getEntity ()
 
 getResource ()
 
 setObject ($object=null)
 
 addItem (\Magento\Framework\DataObject $object)
 
 getAttribute ($attributeCode)
 
 addAttributeToFilter ($attribute, $condition=null, $joinType='inner')
 
 addFieldToFilter ($attribute, $condition=null)
 
 addAttributeToSort ($attribute, $dir=self::SORT_ORDER_ASC)
 
 addAttributeToSelect ($attribute, $joinType=false)
 
 addEntityTypeToSelect ($entityType, $prefix)
 
 addStaticField ($field)
 
 addExpressionAttributeToSelect ($alias, $expression, $attribute)
 
 groupByAttribute ($attribute)
 
 joinAttribute ($alias, $attribute, $bind, $filter=null, $joinType='inner', $storeId=null)
 
 joinField ($alias, $table, $field, $bind, $cond=null, $joinType='inner')
 
 joinTable ($table, $bind, $fields=null, $cond=null, $joinType='inner')
 
 removeAttributeToSelect ($attribute=null)
 
 setPage ($pageNum, $pageSize)
 
 load ($printQuery=false, $logQuery=false)
 
 getAllIds ($limit=null, $offset=null)
 
 getAllIdsSql ()
 
 save ()
 
 delete ()
 
 importFromArray ($arr)
 
 exportToArray ()
 
 getRowIdFieldName ()
 
 getIdFieldName ()
 
 setRowIdFieldName ($fieldName)
 
 _loadAttributes ($printQuery=false, $logQuery=false)
 
 setOrder ($attribute, $dir=self::SORT_ORDER_ASC)
 
 toArray ($arrAttributes=[])
 
 isAttributeAdded ($attributeCode)
 
 getLoadedIds ()
 
 clear ()
 
 removeAllItems ()
 
 removeItemByKey ($key)
 
 getMainTable ()
 
 addFieldToSelect ($field, $alias=null)
 
 removeFieldFromSelect ($field)
 
 removeAllFieldsFromSelect ()
 
- Public Member Functions inherited from AbstractDb
 __construct (EntityFactoryInterface $entityFactory, Logger $logger, FetchStrategyInterface $fetchStrategy, \Magento\Framework\DB\Adapter\AdapterInterface $connection=null)
 
 getResource ()
 
 addBindParam ($name, $value)
 
 getIdFieldName ()
 
 setConnection (\Magento\Framework\DB\Adapter\AdapterInterface $conn)
 
 getSelect ()
 
 getConnection ()
 
 getSize ()
 
 getSelectCountSql ()
 
 getSelectSql ($stringMode=false)
 
 setOrder ($field, $direction=self::SORT_ORDER_DESC)
 
 addOrder ($field, $direction=self::SORT_ORDER_DESC)
 
 unshiftOrder ($field, $direction=self::SORT_ORDER_DESC)
 
 addFieldToFilter ($field, $condition=null)
 
 distinct ($flag)
 
 load ($printQuery=false, $logQuery=false)
 
 loadWithFilter ($printQuery=false, $logQuery=false)
 
 fetchItem ()
 
 getData ()
 
 resetData ()
 
 loadData ($printQuery=false, $logQuery=false)
 
 printLogQuery ($printQuery=false, $logQuery=false, $sql=null)
 
 addFilterToMap ($filter, $alias, $group='fields')
 
 __clone ()
 
 joinExtensionAttribute (JoinDataInterface $join, JoinProcessorInterface $extensionAttributesJoinProcessor)
 
 getItemObjectClass ()
 
 __sleep ()
 
 __wakeup ()
 
- Public Member Functions inherited from Collection
 __construct (EntityFactoryInterface $entityFactory)
 
 addFilter ($field, $value, $type='and')
 
 addFieldToFilter ($field, $condition)
 
 getFilter ($field)
 
 isLoaded ()
 
 getCurPage ($displacement=0)
 
 getLastPageNumber ()
 
 getPageSize ()
 
 getSize ()
 
 getFirstItem ()
 
 getLastItem ()
 
 getItems ()
 
 getColumnValues ($colName)
 
 getItemsByColumnValue ($column, $value)
 
 getItemByColumnValue ($column, $value)
 
 addItem (\Magento\Framework\DataObject $item)
 
 getAllIds ()
 
 removeItemByKey ($key)
 
 removeAllItems ()
 
 clear ()
 
 walk ($callback, array $args=[])
 
 each ($objMethod, $args=[])
 
 setDataToAll ($key, $value=null)
 
 setCurPage ($page)
 
 setPageSize ($size)
 
 setOrder ($field, $direction=self::SORT_ORDER_DESC)
 
 setItemObjectClass ($className)
 
 getNewEmptyItem ()
 
 distinct ($flag)
 
 loadData ($printQuery=false, $logQuery=false)
 
 load ($printQuery=false, $logQuery=false)
 
 loadWithFilter ($printQuery=false, $logQuery=false)
 
 toXml ()
 
 toArray ($arrRequiredFields=[])
 
 toOptionArray ()
 
 toOptionHash ()
 
 getItemById ($idValue)
 
 getIterator ()
 
 count ()
 
 getFlag ($flag)
 
 setFlag ($flag, $value=null)
 
 hasFlag ($flag)
 
 __sleep ()
 
 __wakeup ()
 
- Public Member Functions inherited from SourceProviderInterface
 getSelect ()
 

Protected Member Functions

 _beforeLoad ()
 
 _renderFilters ()
 
- Protected Member Functions inherited from Collection
 _preparePriceExpressionParameters ($select)
 
 _construct ()
 
 _init ($model, $entityModel)
 
 _initTables ()
 
 _prepareStaticFields ()
 
 _initSelect ()
 
 _afterLoad ()
 
 doAddWebsiteNamesToResult ()
 
 _getSelectCountSql (?Select $select=null, $resetLeftJoins=true)
 
 _prepareStatisticsData ()
 
 _getClearSelect ()
 
 _buildClearSelect ($select=null)
 
 _addUrlRewrite ()
 
 getEntityPkName (\Magento\Eav\Model\Entity\AbstractEntity $entity)
 
 _prepareProductLimitationFilters ()
 
 _productLimitationJoinWebsite ()
 
 _productLimitationJoinStore ()
 
 _productLimitationJoinPrice ()
 
 _productLimitationPrice ($joinLeft=false)
 
 _applyProductLimitations ()
 
 _applyZeroStoreProductLimitations ()
 
- Protected Member Functions inherited from AbstractCollection
 getEntityPkName (\Magento\Eav\Model\Entity\AbstractEntity $entity)
 
 _getLoadAttributesSelect ($table, $attributeIds=[])
 
 _addLoadAttributesSelectValues ($select, $table, $type)
 
 _joinAttributeToSelect ($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias)
 
- Protected Member Functions inherited from AbstractCollection
 _construct ()
 
 _prepareStaticFields ()
 
 _initSelect ()
 
 _init ($model, $entityModel)
 
 _prepareOrderExpression ($field)
 
 _getAllIdsSelect ($limit=null, $offset=null)
 
 _getLoadAttributesSelect ($table, $attributeIds=[])
 
 _addLoadAttributesSelectValues ($select, $table, $type)
 
 _setItemAttributeValue ($valueInfo)
 
 _getAttributeTableAlias ($attributeCode)
 
 _getAttributeFieldName ($attributeCode)
 
 _addAttributeJoin ($attributeCode, $joinType='inner')
 
 getEntityPkName (\Magento\Eav\Model\Entity\AbstractEntity $entity)
 
 _joinAttributeToSelect ($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias)
 
 _getAttributeConditionSql ($attribute, $condition, $joinType='inner')
 
 _renderOrders ()
 
 _afterLoad ()
 
 _reset ()
 
- Protected Member Functions inherited from AbstractDb
 _setIdFieldName ($fieldName)
 
 _getItemId (\Magento\Framework\DataObject $item)
 
 _renderFilters ()
 
 _renderFiltersBefore ()
 
 _translateCondition ($field, $condition)
 
 _getMappedField ($field)
 
 _getMapper ()
 
 _getConditionSql ($fieldName, $condition)
 
 _getConditionFieldName ($fieldName)
 
 _renderOrders ()
 
 _renderLimit ()
 
 _beforeLoad ()
 
 beforeAddLoadedItem (\Magento\Framework\DataObject $item)
 
 _toOptionArray ($valueField=null, $labelField='name', $additional=[])
 
 _toOptionHash ($valueField=null, $labelField='name')
 
 _afterLoadData ()
 
 _afterLoad ()
 
 _logQuery ($sql)
 
 _reset ()
 
 _fetchAll (Select $select)
 
 _initSelect ()
 
- Protected Member Functions inherited from Collection
 _setIsLoaded ($flag=true)
 
 _addItem ($item)
 
 _getItemId (\Magento\Framework\DataObject $item)
 
 _renderFilters ()
 
 _renderOrders ()
 
 _renderLimit ()
 
 _toOptionArray ($valueField='id', $labelField='name', $additional=[])
 
 _toOptionHash ($valueField='id', $labelField='name')
 

Protected Attributes

 $queryResponse
 
 $queryFactory = null
 
- Protected Attributes inherited from Collection
 $_idFieldName = 'entity_id'
 
 $_flatEnabled = []
 
 $_productWebsiteTable
 
 $_productCategoryTable
 
 $_addUrlRewrite = false
 
 $_urlRewriteCategory = ''
 
 $_addFinalPrice = false
 
 $_allIdsCache = null
 
 $_addTaxPercents = false
 
 $_productLimitationFilters
 
 $_productCountSelect = null
 
 $_isWebsiteFilter = false
 
 $_priceDataFieldFilters = []
 
 $_priceExpression
 
 $_additionalPriceExpression
 
 $_maxPrice
 
 $_minPrice
 
 $_priceStandardDeviation
 
 $_pricesCount = null
 
 $_catalogPreparePriceSelect = null
 
 $_catalogProductFlatState = null
 
 $moduleManager = null
 
 $_scopeConfig
 
 $_customerSession
 
 $_localeDate
 
 $_catalogUrl
 
 $_productOptionFactory
 
 $_resourceHelper
 
 $dateTime
 
 $_groupManagement
 
 $needToAddWebsiteNamesToResult
 
- Protected Attributes inherited from AbstractCollection
 $_storeId
 
 $_storeManager
 
- Protected Attributes inherited from AbstractCollection
 $_itemsById = []
 
 $_staticFields = []
 
 $_entity
 
 $_selectEntityTypes = []
 
 $_selectAttributes = []
 
 $_filterAttributes = []
 
 $_joinEntities = []
 
 $_joinAttributes = []
 
 $_joinFields = []
 
 $_castToIntMap = ['validate-digits']
 
 $_eventManager = null
 
 $_eavConfig
 
 $_resource
 
 $_eavEntityFactory
 
 $_resourceHelper
 
 $_universalFactory
 
- Protected Attributes inherited from AbstractDb
 $_conn
 
 $_select
 
 $_idFieldName
 
 $_bindParams = []
 
 $_data = null
 
 $_map = null
 
 $_fetchStmt = null
 
 $_isOrdersRendered = false
 
 $_logger
 
 $extensionAttributesJoinProcessor
 
- Protected Attributes inherited from Collection
 $_items = []
 
 $_itemObjectClass = \Magento\Framework\DataObject::class
 
 $_orders = []
 
 $_filters = []
 
 $_isFiltersRendered = false
 
 $_curPage = 1
 
 $_pageSize = false
 
 $_totalRecords
 
 $_isCollectionLoaded
 
 $_flags = []
 
 $_entityFactory
 

Additional Inherited Members

- Data Fields inherited from Collection
const INDEX_TABLE_ALIAS = 'price_index'
 
const MAIN_TABLE_ALIAS = 'e'
 
- Data Fields inherited from AbstractCollection
const ATTRIBUTE_TABLE_ALIAS_PREFIX = 'at_'
 
- Data Fields inherited from Collection
const SORT_ORDER_ASC = 'ASC'
 
const SORT_ORDER_DESC = 'DESC'
 

Detailed Description

Fulltext Collection

This collection should be refactored to not have dependencies on MySQL-specific implementation.

@api

Since
100.0.2 @SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 30 of file Collection.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Data\Collection\EntityFactory  $entityFactory,
\Psr\Log\LoggerInterface  $logger,
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface  $fetchStrategy,
\Magento\Framework\Event\ManagerInterface  $eventManager,
\Magento\Eav\Model\Config  $eavConfig,
\Magento\Framework\App\ResourceConnection  $resource,
\Magento\Eav\Model\EntityFactory  $eavEntityFactory,
\Magento\Catalog\Model\ResourceModel\Helper  $resourceHelper,
\Magento\Framework\Validator\UniversalFactory  $universalFactory,
\Magento\Store\Model\StoreManagerInterface  $storeManager,
\Magento\Framework\Module\Manager  $moduleManager,
\Magento\Catalog\Model\Indexer\Product\Flat\State  $catalogProductFlatState,
\Magento\Framework\App\Config\ScopeConfigInterface  $scopeConfig,
\Magento\Catalog\Model\Product\OptionFactory  $productOptionFactory,
\Magento\Catalog\Model\ResourceModel\Url  $catalogUrl,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface  $localeDate,
\Magento\Customer\Model\Session  $customerSession,
\Magento\Framework\Stdlib\DateTime  $dateTime,
\Magento\Customer\Api\GroupManagementInterface  $groupManagement,
\Magento\Search\Model\QueryFactory  $catalogSearchData,
\Magento\Framework\Search\Request\Builder  $requestBuilder,
\Magento\Search\Model\SearchEngine  $searchEngine,
\Magento\Framework\Search\Adapter\Mysql\TemporaryStorageFactory  $temporaryStorageFactory,
\Magento\Framework\DB\Adapter\AdapterInterface  $connection = null,
  $searchRequestName = 'catalog_view_container',
SearchResultFactory  $searchResultFactory = null,
ProductLimitationFactory  $productLimitationFactory = null,
MetadataPool  $metadataPool = null 
)

Collection constructor

Parameters
\Magento\Framework\Data\Collection\EntityFactory$entityFactory
\Psr\Log\LoggerInterface$logger
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface$fetchStrategy
\Magento\Framework\Event\ManagerInterface$eventManager
\Magento\Eav\Model\Config$eavConfig
\Magento\Framework\App\ResourceConnection$resource
\Magento\Eav\Model\EntityFactory$eavEntityFactory
\Magento\Catalog\Model\ResourceModel\Helper$resourceHelper
\Magento\Framework\Validator\UniversalFactory$universalFactory
\Magento\Store\Model\StoreManagerInterface$storeManager
\Magento\Framework\Module\Manager$moduleManager
\Magento\Catalog\Model\Indexer\Product\Flat\State$catalogProductFlatState
\Magento\Framework\App\Config\ScopeConfigInterface$scopeConfig
\Magento\Catalog\Model\Product\OptionFactory$productOptionFactory
\Magento\Catalog\Model\ResourceModel\Url$catalogUrl
\Magento\Framework\Stdlib\DateTime\TimezoneInterface$localeDate
\Magento\Customer\Model\Session$customerSession
\Magento\Framework\Stdlib\DateTime$dateTime
\Magento\Customer\Api\GroupManagementInterface$groupManagement
\Magento\Search\Model\QueryFactory$catalogSearchData
\Magento\Framework\Search\Request\Builder$requestBuilder
\Magento\Search\Model\SearchEngine$searchEngine
\Magento\Framework\Search\Adapter\Mysql\TemporaryStorageFactory$temporaryStorageFactory
\Magento\Framework\DB\Adapter\AdapterInterface | null$connection
string$searchRequestName
SearchResultFactory | null$searchResultFactory
ProductLimitationFactory | null$productLimitationFactory
MetadataPool | null$metadataPool@SuppressWarnings(PHPMD.ExcessiveParameterList)

Definition at line 138 of file Collection.php.

167  {
168  $this->queryFactory = $catalogSearchData;
169  if ($searchResultFactory === null) {
170  $this->searchResultFactory = \Magento\Framework\App\ObjectManager::getInstance()
171  ->get(\Magento\Framework\Api\Search\SearchResultFactory::class);
172  }
173  parent::__construct(
174  $entityFactory,
175  $logger,
176  $fetchStrategy,
177  $eventManager,
178  $eavConfig,
179  $resource,
180  $eavEntityFactory,
181  $resourceHelper,
182  $universalFactory,
185  $catalogProductFlatState,
186  $scopeConfig,
187  $productOptionFactory,
188  $catalogUrl,
189  $localeDate,
190  $customerSession,
191  $dateTime,
192  $groupManagement,
193  $connection,
194  $productLimitationFactory,
195  $metadataPool
196  );
197  $this->requestBuilder = $requestBuilder;
198  $this->searchEngine = $searchEngine;
199  $this->temporaryStorageFactory = $temporaryStorageFactory;
200  $this->searchRequestName = $searchRequestName;
201  }
$storeManager
$resource
Definition: bulk.php:12
$logger
$connection
Definition: bulk.php:13

Member Function Documentation

◆ _beforeLoad()

_beforeLoad ( )
protected
Since
100.2.3

Definition at line 391 of file Collection.php.

392  {
393  /*
394  * This order is required to force search results be the same
395  * for the same requests and products with the same relevance
396  * NOTE: this does not replace existing orders but ADDs one more
397  */
398  $this->setOrder('entity_id');
399  return parent::_beforeLoad();
400  }

◆ _renderFilters()

_renderFilters ( )
protected

Render filters.

Returns
$this

Definition at line 407 of file Collection.php.

408  {
409  $this->_filters = [];
410  return parent::_renderFilters();
411  }

◆ addCategoryFilter()

addCategoryFilter ( \Magento\Catalog\Model\Category  $category)

Specify category filter for product collection

Parameters
\Magento\Catalog\Model\Category$category
Returns
$this

Definition at line 474 of file Collection.php.

475  {
476  $this->addFieldToFilter('category_ids', $category->getId());
477  return parent::addCategoryFilter($category);
478  }

◆ addFieldToFilter()

addFieldToFilter (   $field,
  $condition = null 
)

Apply attribute filter to facet collection

Parameters
string$field
mixed | null$condition
Returns
$this

Implements SourceProviderInterface.

Definition at line 292 of file Collection.php.

293  {
294  if ($this->searchResult !== null) {
295  throw new \RuntimeException('Illegal state');
296  }
297 
298  $this->getSearchCriteriaBuilder();
299  $this->getFilterBuilder();
300  if (!is_array($condition) || !in_array(key($condition), ['from', 'to'], true)) {
301  $this->filterBuilder->setField($field);
302  $this->filterBuilder->setValue($condition);
303  $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
304  } else {
305  if (!empty($condition['from'])) {
306  $this->filterBuilder->setField("{$field}.from");
307  $this->filterBuilder->setValue($condition['from']);
308  $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
309  }
310  if (!empty($condition['to'])) {
311  $this->filterBuilder->setField("{$field}.to");
312  $this->filterBuilder->setValue($condition['to']);
313  $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
314  }
315  }
316  return $this;
317  }

◆ addSearchFilter()

addSearchFilter (   $query)

Add search query filter

Parameters
string$query
Returns
$this

Definition at line 325 of file Collection.php.

326  {
327  $this->queryText = trim($this->queryText . ' ' . $query);
328  return $this;
329  }

◆ getFacetedData()

getFacetedData (   $field)

Return field faceted data from faceted search result

Parameters
string$field
Returns
array
Exceptions
StateException

Definition at line 448 of file Collection.php.

449  {
450  $this->_renderFilters();
451  $result = [];
452  $aggregations = $this->searchResult->getAggregations();
453  // This behavior is for case with empty object when we got EmptyRequestDataException
454  if (null !== $aggregations) {
455  $bucket = $aggregations->getBucket($field . RequestGenerator::BUCKET_SUFFIX);
456  if ($bucket) {
457  foreach ($bucket->getValues() as $value) {
458  $metrics = $value->getMetrics();
459  $result[$metrics['value']] = $metrics;
460  }
461  } else {
462  throw new StateException(__("The bucket doesn't exist."));
463  }
464  }
465  return $result;
466  }
__()
Definition: __.php:13
$value
Definition: gender.phtml:16

◆ setFilterBuilder()

setFilterBuilder ( \Magento\Framework\Api\FilterBuilder  $object)

Set filter builder.

Deprecated:
100.1.0
Parameters
\Magento\Framework\Api\FilterBuilder$object
Returns
void
Since
100.1.0

Definition at line 280 of file Collection.php.

281  {
282  $this->filterBuilder = $object;
283  }

◆ setGeneralDefaultQuery()

setGeneralDefaultQuery ( )

Stub method for compatibility with other search engines

Returns
$this

Definition at line 436 of file Collection.php.

437  {
438  return $this;
439  }

◆ setOrder()

setOrder (   $attribute,
  $dir = Select::SQL_DESC 
)

Set Order field

Parameters
string$attribute
string$dir
Returns
$this

Definition at line 420 of file Collection.php.

421  {
422  if ($attribute === 'relevance') {
423  $this->relevanceOrderDirection = $dir;
424  } else {
425  parent::setOrder($attribute, $dir);
426  }
427 
428  return $this;
429  }

◆ setSearch()

setSearch ( \Magento\Search\Api\SearchInterface  $object)

Test search.

Deprecated:
100.1.0
Parameters
\Magento\Search\Api\SearchInterface$object
Returns
void
Since
100.1.0

Definition at line 225 of file Collection.php.

226  {
227  $this->search = $object;
228  }

◆ setSearchCriteriaBuilder()

setSearchCriteriaBuilder ( \Magento\Framework\Api\Search\SearchCriteriaBuilder  $object)

Set search criteria builder.

Deprecated:
100.1.0
Parameters
\Magento\Framework\Api\Search\SearchCriteriaBuilder$object
Returns
void
Since
100.1.0

Definition at line 253 of file Collection.php.

254  {
255  $this->searchCriteriaBuilder = $object;
256  }

◆ setVisibility()

setVisibility (   $visibility)

Set product visibility filter for enabled products

Parameters
array$visibility
Returns
$this

Definition at line 486 of file Collection.php.

487  {
488  $this->addFieldToFilter('visibility', $visibility);
489  return parent::setVisibility($visibility);
490  }

Field Documentation

◆ $queryFactory

$queryFactory = null
protected

Definition at line 44 of file Collection.php.

◆ $queryResponse

$queryResponse
protected

Definition at line 36 of file Collection.php.


The documentation for this class was generated from the following file: