idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
44,000
private function getStoreId ( Category $ category ) { $ storeId = $ category -> getStoreId ( ) ; if ( $ storeId === 0 ) { $ defaultStoreId = $ this -> getDefaultStoreId ( ) ; $ categoryStoreIds = array_filter ( $ category -> getStoreIds ( ) ) ; $ storeId = current ( $ categoryStoreIds ) ; if ( in_array ( $ defaultStore...
Get store id for the current category .
44,001
private function doSearch ( RequestInterface $ request ) { $ searchRequest = [ 'index' => $ request -> getIndex ( ) , 'type' => $ request -> getType ( ) , 'body' => $ this -> requestMapper -> buildSearchRequest ( $ request ) , ] ; return $ this -> client -> search ( $ searchRequest ) ; }
Execute the search request with ES .
44,002
public function loadCategoryData ( $ storeId , $ productIds ) { $ select = $ this -> getCategoryProductSelect ( $ productIds , $ storeId ) ; $ categoryData = $ this -> getConnection ( ) -> fetchAll ( $ select ) ; $ categoryIds = [ ] ; foreach ( $ categoryData as $ categoryDataRow ) { $ categoryIds [ ] = $ categoryDataR...
Load categories data for a list of product ids and a given store .
44,003
protected function getCategoryProductSelect ( $ productIds , $ storeId ) { $ select = $ this -> getConnection ( ) -> select ( ) -> from ( [ 'cpi' => $ this -> getTable ( $ this -> getCategoryProductIndexTable ( $ storeId ) ) ] ) -> where ( 'cpi.store_id = ?' , $ storeId ) -> where ( 'cpi.product_id IN(?)' , $ productId...
Prepare indexed data select .
44,004
protected function getCategoryNameAttribute ( ) { $ this -> categoryNameAttribute = $ this -> eavConfig -> getAttribute ( \ Magento \ Catalog \ Model \ Category :: ENTITY , 'name' ) ; return $ this -> categoryNameAttribute ; }
Returns category name attribute
44,005
protected function getUseNameInSearchAttribute ( ) { $ this -> useNameInSearchAttribute = $ this -> eavConfig -> getAttribute ( \ Magento \ Catalog \ Model \ Category :: ENTITY , 'use_name_in_product_search' ) ; return $ this -> useNameInSearchAttribute ; }
Returns category use name in product search attribute
44,006
private function loadCategoryNames ( $ categoryIds , $ storeId ) { $ loadCategoryIds = $ categoryIds ; if ( isset ( $ this -> categoryNameCache [ $ storeId ] ) ) { $ loadCategoryIds = array_diff ( $ categoryIds , array_keys ( $ this -> categoryNameCache [ $ storeId ] ) ) ; } $ loadCategoryIds = array_map ( 'intval' , $...
Add some categories name into the cache of names of categories .
44,007
private function prepareCategoryNameSelect ( $ loadCategoryIds , $ storeId ) { $ rootCategoryId = ( int ) $ this -> storeManager -> getStore ( $ storeId ) -> getRootCategoryId ( ) ; $ this -> categoryNameCache [ $ storeId ] [ $ rootCategoryId ] = '' ; $ nameAttr = $ this -> getCategoryNameAttribute ( ) ; $ useNameAttr ...
Prepare SQL query to retrieve category names
44,008
public function getOptionIds ( Attribute $ attribute , $ labels ) { $ optionIds = [ ] ; if ( ! is_array ( $ labels ) ) { $ labels = [ $ labels ] ; } $ options = $ attribute -> getSource ( ) -> getAllOptions ( ) ; foreach ( $ labels as $ label ) { foreach ( $ options as $ option ) { if ( $ option [ 'label' ] == $ label ...
Retrive options ids from a labels array .
44,009
private function loadVariationsFromSearchIndex ( Product $ parentProduct , array $ attributes ) { $ documentSource = $ parentProduct -> getDocumentSource ( ) ; $ childrenIds = isset ( $ documentSource [ 'children_ids' ] ) ? $ documentSource [ 'children_ids' ] : [ ] ; $ variation = false ; if ( ! empty ( $ childrenIds )...
Load variations for a given product with data coming from the search index .
44,010
private function addFilterByParent ( ProductCollection $ productCollection , $ parentId ) { $ tableProductRelation = $ productCollection -> getTable ( 'catalog_product_relation' ) ; $ productCollection -> getSelect ( ) -> join ( [ 'pr' => $ tableProductRelation ] , 'e.entity_id = pr.child_id' ) -> where ( 'pr.parent_id...
Filter a collection by its parent . Inherited method since it s private in the parent .
44,011
public function toOptionArray ( ) { return [ [ 'label' => __ ( 'Auto' ) , 'value' => self :: AUTO_DISPLAYED ] , [ 'label' => __ ( 'Always hidden' ) , 'value' => self :: ALWAYS_HIDDEN ] , [ 'label' => __ ( 'Always displayed' ) , 'value' => self :: ALWAYS_DISPLAYED ] , ] ; }
Return array of display mode
44,012
private function getCurrentCategory ( ) { $ category = false ; if ( $ this -> registry -> registry ( 'current_category' ) && $ this -> registry -> registry ( 'current_category' ) -> getId ( ) ) { $ category = $ this -> registry -> registry ( 'current_category' ) ; } return $ category ; }
Get the currently edited category if any .
44,013
private function cleanCategoryCacheByIds ( array $ categoryIds ) { $ this -> cacheContext -> registerEntities ( \ Magento \ Catalog \ Model \ Category :: CACHE_TAG , $ categoryIds ) ; $ this -> eventManager -> dispatch ( 'clean_cache_by_tags' , [ 'object' => $ this -> cacheContext ] ) ; }
Clean cache of frontend pages based on category ids .
44,014
public function validateFilter ( $ filter ) { $ regexp = "/(-?[0-9]+)-(-?[0-9]+)/" ; preg_match_all ( $ regexp , $ filter , $ matches ) ; if ( count ( $ matches ) !== 3 ) { return false ; } $ filter = [ current ( $ matches [ 1 ] ) , current ( $ matches [ 2 ] ) ] ; foreach ( $ filter as $ v ) { if ( is_infinite ( ( doub...
Validate and parse filter request param .
44,015
private function addCustomerLink ( $ eventData ) { if ( $ this -> customerSession -> getCustomerId ( ) !== null ) { $ customerId = $ this -> customerSession -> getCustomerId ( ) ; $ sessionId = $ eventData [ 'session' ] [ 'uid' ] ?? null ; $ visitorId = $ eventData [ 'session' ] [ 'vid' ] ?? null ; if ( $ sessionId && ...
Save customer link if the current customer is logged in .
44,016
private function getNewParentTree ( $ category ) { $ pathIds = array_reverse ( explode ( ',' , $ category -> getPathInStore ( ) ) ) ; $ pathIds [ ] = $ category -> getId ( ) ; $ categories = $ this -> categoryCollectionFactory -> create ( ) ; return $ categories -> setStore ( $ this -> storeManager -> getStore ( ) ) ->...
Return parent categories of category
44,017
public function create ( array $ rawAggregations ) { $ buckets = $ this -> getBuckets ( $ rawAggregations ) ; return $ this -> aggregationFactory -> create ( [ 'buckets' => $ buckets ] ) ; }
Build a aggregation object from the search engine response .
44,018
private function getBuckets ( $ rawAggregations ) { $ buckets = [ ] ; foreach ( $ rawAggregations as $ bucketName => $ rawBucket ) { while ( isset ( $ rawBucket [ $ bucketName ] ) ) { $ rawBucket = $ rawBucket [ $ bucketName ] ; } $ bucketParams = [ 'name' => $ bucketName , 'values' => $ this -> getBucketValues ( $ raw...
Return buckets from an ES aggregation .
44,019
private function getBucketValues ( $ rawBucket ) { $ values = [ ] ; if ( isset ( $ rawBucket [ 'sum_other_doc_count' ] ) && $ rawBucket [ 'sum_other_doc_count' ] > 0 ) { $ rawBucket [ 'buckets' ] [ '__other_docs' ] [ 'doc_count' ] = $ rawBucket [ 'sum_other_doc_count' ] ; } foreach ( $ rawBucket [ 'buckets' ] as $ key ...
Return a bucket from an ES aggregation .
44,020
private function getMetrics ( $ rawValue ) { $ metrics = [ ] ; foreach ( $ rawValue as $ metricName => $ value ) { if ( ! is_array ( $ value ) || ! isset ( $ value [ 'buckets' ] ) ) { $ metricName = $ metricName == 'doc_count' ? 'count' : $ metricName ; if ( is_array ( $ value ) && isset ( $ value [ 'value_as_string' ]...
Parse a bucket and returns metrics .
44,021
private function getSubAggregations ( $ rawValue ) { $ subAggregations = [ ] ; foreach ( $ rawValue as $ key => $ value ) { if ( is_array ( $ value ) ) { while ( is_array ( $ value ) && isset ( $ value [ $ key ] ) && is_array ( $ value [ $ key ] ) ) { $ value = $ value [ $ key ] ; } if ( isset ( $ value [ 'buckets' ] )...
Parse a bucket and returns sub - aggregations .
44,022
public function create ( $ storeId , $ containerName ) { $ scopeCode = $ this -> getScopeCode ( $ storeId , $ containerName ) ; if ( ! isset ( $ this -> cachedConfig [ $ scopeCode ] ) ) { $ instanceConfiguration = $ this -> loadConfiguration ( $ scopeCode ) ; $ this -> cachedConfig [ $ scopeCode ] = $ this -> objectMan...
Retrieve relevance configuration for a container .
44,023
protected function loadConfiguration ( $ scopeCode ) { $ configurationParams = [ 'minimumShouldMatch' => $ this -> getMinimumShouldMatch ( $ scopeCode ) , 'tieBreaker' => $ this -> getTieBreaker ( $ scopeCode ) , 'phraseMatchBoost' => $ this -> getPhraseMatchBoostConfiguration ( $ scopeCode ) , 'cutOffFrequency' => $ t...
Load the relevance configuration by scope code .
44,024
protected function getConfigValue ( $ path , $ scopeCode ) { $ scope = ContainerScopeInterface :: SCOPE_STORE_CONTAINERS ; return $ this -> scopeConfig -> getValue ( $ path , $ scope , $ scopeCode ) ; }
Read value into the config by path and scope .
44,025
private function getFuzzinessConfiguration ( $ scopeCode ) { $ path = self :: FUZZINESS_CONFIG_XML_PREFIX ; $ configuration = ( bool ) $ this -> getConfigValue ( $ path . "/enable" , $ scopeCode ) ; if ( $ configuration === true ) { $ configurationParams = [ 'value' => $ this -> getConfigValue ( $ path . "/value" , $ s...
Retrieve fuzziness configuration object .
44,026
private function getPhraseMatchBoostConfiguration ( $ scopeCode ) { $ path = self :: BASE_RELEVANCE_CONFIG_XML_PREFIX . "/" . self :: PHRASE_MATCH_CONFIG_XML_PREFIX ; $ boost = ( bool ) $ this -> getConfigValue ( $ path . "/enable_phrase_match" , $ scopeCode ) ; if ( $ boost === true ) { $ boost = ( int ) $ this -> get...
Retrieve phrase boost configuration for a container .
44,027
private function getMinimumShouldMatch ( $ scopeCode ) { $ path = self :: BASE_RELEVANCE_CONFIG_XML_PREFIX . "/" . self :: MINIMUM_SHOULD_MATCH_CONFIG_XML_PATH ; return $ this -> getConfigValue ( $ path , $ scopeCode ) ; }
Retrieve minimum should match config for a container .
44,028
private function getTieBreaker ( $ scopeCode ) { $ path = self :: BASE_RELEVANCE_CONFIG_XML_PREFIX . "/" . self :: TIE_BREAKER_CONFIG_XML_PATH ; return ( float ) $ this -> getConfigValue ( $ path , $ scopeCode ) ; }
Retrieve tie breaker config for a container .
44,029
private function getCutoffFrequencyConfiguration ( $ scopeCode ) { $ path = self :: BASE_RELEVANCE_CONFIG_XML_PREFIX . "/" . self :: CUTOFF_FREQUENCY_CONFIG_XML_PATH ; return ( float ) $ this -> getConfigValue ( $ path , $ scopeCode ) ; }
Retrieve cutoff frequency for a container .
44,030
private function getSessionIdsByStore ( $ events ) { $ sessionIdsByStore = [ ] ; foreach ( $ events as $ event ) { if ( isset ( $ event [ 'page' ] [ 'store_id' ] ) && isset ( $ event [ 'session' ] [ 'uid' ] ) ) { $ sessionIdsByStore [ $ event [ 'page' ] [ 'store_id' ] ] [ ] = $ event [ 'session' ] [ 'uid' ] ?? 0 ; } } ...
Extract session ids from event by store .
44,031
private function getDefaultSearchProperty ( $ field = self :: DEFAULT_SEARCH_FIELD , $ analyzer = null ) { if ( ! isset ( $ this -> defaultMappingFields [ $ field ] ) ) { throw new \ InvalidArgumentException ( "Unable to find field {$field}." ) ; } $ property = $ field ; if ( $ analyzer !== null ) { if ( ! in_array ( $...
Return the search property for a field present in defaultMappingFields .
44,032
private function prepareFields ( array $ fields ) { $ preparedFields = [ ] ; foreach ( $ fields as $ field ) { $ preparedFields [ $ field -> getName ( ) ] = $ field ; } return $ preparedFields ; }
Prepare the array of fields to be added to the mapping . Mostly rekey the array .
44,033
private function addProperty ( array $ properties , $ propertyName , $ propertyType , $ analyzers = [ ] ) { $ property = [ 'type' => $ propertyType , 'analyzer' => FieldInterface :: ANALYZER_STANDARD ] ; foreach ( $ analyzers as $ analyzer ) { if ( $ analyzer !== FieldInterface :: ANALYZER_STANDARD ) { $ property [ 'fi...
Append a new properties into a properties list and returned the updated map .
44,034
private function addField ( array $ properties , FieldInterface $ field ) { $ fieldName = $ field -> getName ( ) ; $ fieldRoot = & $ properties ; $ property = $ field -> getMappingPropertyConfig ( ) ; $ fieldPathArray = explode ( '.' , $ fieldName ) ; $ currentPathArray = [ ] ; $ fieldPathSize = count ( $ fieldPathArra...
Append a field to a mapping properties list . The field is append and the new properties list is returned .
44,035
public function loadChildrens ( $ productIds , $ storeId ) { $ children = [ ] ; foreach ( $ this -> catalogProductType -> getCompositeTypes ( ) as $ productTypeId ) { $ typeInstance = $ this -> getProductTypeInstance ( $ productTypeId ) ; $ relation = $ typeInstance -> getRelationInfo ( ) ; if ( $ relation -> getTable ...
Retrieve list of children ids for a product list .
44,036
protected function getProductTypeInstance ( $ typeId ) { if ( ! isset ( $ this -> productTypes [ $ typeId ] ) ) { $ productEmulator = $ this -> getProductEmulator ( $ typeId ) ; $ this -> productTypes [ $ typeId ] = $ this -> catalogProductType -> factory ( $ productEmulator ) ; } return $ this -> productTypes [ $ type...
Retrieve product type instance from identifier .
44,037
private function addWebsiteFilter ( \ Magento \ Framework \ DB \ Select $ select , $ productTableName , $ productFieldName , $ storeId ) { $ websiteId = $ this -> getStore ( $ storeId ) -> getWebsiteId ( ) ; $ indexTable = $ this -> getTable ( 'catalog_product_website' ) ; $ visibilityJoinCond = $ this -> getConnection...
Add website clauses to products selected .
44,038
private function fillQueryData ( $ queryIds ) { $ data = [ ] ; $ collection = $ this -> queryCollection -> addFieldToFilter ( 'query_id' , $ queryIds ) ; $ yesNoValues = $ this -> yesNo -> toArray ( ) ; foreach ( $ collection as $ query ) { $ data [ ] = [ 'id' => $ query -> getId ( ) , 'query_text' => $ query -> getQue...
Get query data to fill the dynamicRows in Ui Component Form .
44,039
public function rebuildStoreIndex ( $ storeId , $ categoryIds = null ) { $ lastCategoryId = 0 ; do { $ categories = $ this -> getSearchableCategories ( $ storeId , $ categoryIds , $ lastCategoryId ) ; foreach ( $ categories as $ categoryData ) { $ lastCategoryId = ( int ) $ categoryData [ 'entity_id' ] ; yield $ lastCa...
Get data for a list of categories in a store id . If the product list ids is null all categories data will be loaded .
44,040
public function create ( $ providerType , $ providerParams = [ ] ) { if ( ! isset ( $ this -> factories [ $ providerType ] ) ) { throw new \ LogicException ( "No factory found for provider of type {$providerType}" ) ; } return $ this -> factories [ $ providerType ] -> create ( $ providerParams ) ; }
Create an Optimizer Collection provider from it s type and params .
44,041
public function getVariables ( ) { $ variables = array_merge ( $ this -> getCategoryVariables ( ) , $ this -> getProductVariables ( ) , $ this -> getProductListVariables ( ) , $ this -> getLayerVariables ( ) ) ; return $ variables ; }
Return the list of catalog related variables .
44,042
public function getScope ( $ scopeType , $ scopeCode = null ) { $ scopeCode = $ this -> scopeCodeResolver -> resolve ( $ scopeType , $ scopeCode ) ; $ code = $ scopeType . '|' . $ scopeCode ; if ( ! isset ( $ this -> scopes [ $ code ] ) ) { $ cacheKey = $ this -> cacheId . '|' . $ code ; $ data = $ this -> cache -> loa...
Retrieve config section
44,043
private function getProductPrice ( ProductInterface $ product ) { $ price = 0 ; $ document = $ this -> getDocumentSource ( $ product ) ; if ( isset ( $ document [ 'price' ] ) ) { foreach ( $ document [ 'price' ] as $ currentPrice ) { if ( ( int ) $ price [ 'customer_group_id' ] === GroupInterface :: NOT_LOGGED_IN_ID ) ...
Returns current product sale price .
44,044
private function isInStockProduct ( ProductInterface $ product ) { $ isInStock = false ; $ document = $ this -> getDocumentSource ( $ product ) ; if ( isset ( $ document [ 'stock' ] [ 'is_in_stock' ] ) ) { $ isInStock = ( bool ) $ document [ 'stock' ] [ 'is_in_stock' ] ; } return $ isInStock ; }
Returns current product stock status .
44,045
private function loadSpellingType ( RequestInterface $ request ) { $ spellingType = self :: SPELLING_TYPE_FUZZY ; try { $ cutoffFrequencyLimit = $ this -> getCutoffrequencyLimit ( $ request ) ; $ termVectors = $ this -> getTermVectors ( $ request ) ; $ queryTermStats = $ this -> parseTermVectors ( $ termVectors , $ cut...
Compute the spelling time using the engine .
44,046
private function getCacheKey ( RequestInterface $ request ) { return implode ( '|' , [ $ request -> getIndex ( ) , $ request -> getType ( ) , $ request -> getQueryText ( ) ] ) ; }
Compute an unique caching key for the spellcheck request .
44,047
private function getTermVectors ( RequestInterface $ request ) { $ termVectorsQuery = [ 'index' => $ request -> getIndex ( ) , 'type' => $ request -> getType ( ) , 'term_statistics' => true , 'fields' => [ MappingInterface :: DEFAULT_SPELLING_FIELD , MappingInterface :: DEFAULT_SPELLING_FIELD . "." . FieldInterface :: ...
Run a term vectors query against the index and return the result .
44,048
private function extractTermStatsByPoisition ( $ termVectors ) { $ statByPosition = [ ] ; $ analyzers = [ FieldInterface :: ANALYZER_STANDARD , FieldInterface :: ANALYZER_WHITESPACE ] ; foreach ( $ termVectors [ 'term_vectors' ] as $ propertyName => $ fieldData ) { $ analyzer = $ this -> getAnalyzer ( $ propertyName ) ...
Extract term stats by position from a term vectors query response . Wil return an array of doc_freq analayzers and term by position .
44,049
private function getAnalyzer ( $ propertyName ) { $ analyzer = FieldInterface :: ANALYZER_STANDARD ; if ( strstr ( $ propertyName , '.' ) ) { $ propertyNameParts = explode ( '.' , $ propertyName ) ; $ analyzer = end ( $ propertyNameParts ) ; } return $ analyzer ; }
Extract analayser from a mapping property name .
44,050
public function getSearchableCategories ( $ storeId , $ categoryIds = null , $ fromId = 0 , $ limit = 100 ) { $ categoryCollection = $ this -> categoryCollectionFactory -> create ( ) ; $ categoryCollection -> addIsActiveFilter ( ) ; $ select = $ categoryCollection -> getSelect ( ) ; $ this -> addIsVisibleInStoreFilter ...
Load a bulk of category data .
44,051
private function addIsVisibleInStoreFilter ( $ select , $ storeId ) { $ rootCategoryId = $ this -> getRootCategoryId ( $ storeId ) ; $ select -> where ( 'e.path LIKE ?' , "1/{$rootCategoryId}%" ) ; return $ this ; }
Filter the select to append only categories that are childrens of the root category of current store .
44,052
public function getVariables ( ) { $ variables = [ ] ; if ( $ this -> page -> getId ( ) ) { $ variables [ 'cms.identifier' ] = $ this -> page -> getIdentifier ( ) ; $ variables [ 'cms.title' ] = $ this -> page -> getTitle ( ) ; } return $ variables ; }
Append the CMS page viewed identifier and title to the list of tracked variables
44,053
public function execute ( \ Magento \ Framework \ Event \ Observer $ observer ) { $ cookieNames = $ this -> getCookies ( ) ; $ metadata = $ this -> cookieMetadataFactory -> createPublicCookieMetadata ( ) ; $ metadata -> setPath ( $ this -> getCookieConfiguration ( ) [ 'path' ] ?? '/' ) ; foreach ( $ cookieNames as $ co...
Clean customer tracking cookies when logging out .
44,054
private function getCookies ( ) { $ cookieConfiguration = $ this -> getCookieConfiguration ( ) ; $ cookies = [ $ cookieConfiguration [ 'visit_cookie_name' ] ?? null , $ cookieConfiguration [ 'visitor_cookie_name' ] ?? null , ] ; return array_filter ( $ cookies ) ; }
Retrieve cookies names from configuration .
44,055
public function execute ( \ Magento \ Framework \ Event \ Observer $ observer ) { $ entity = $ observer -> getEntity ( ) ; if ( $ entity -> getVirtualRule ( ) !== null ) { $ this -> saveHandler -> execute ( $ entity ) ; } }
Observer listening to magento_catalog_api_data_categoryinterface_save_before
44,056
protected function getMinValue ( ) { $ minValue = $ this -> getFilter ( ) -> getMinValue ( ) ; if ( $ this -> isManualCalculation ( ) && ( $ this -> getStepValue ( ) > 0 ) ) { $ stepValue = $ this -> getStepValue ( ) ; $ minValue = floor ( $ minValue / $ stepValue ) * $ stepValue ; } return $ minValue ; }
Returns min value of the slider .
44,057
protected function getMaxValue ( ) { $ maxValue = $ this -> getFilter ( ) -> getMaxValue ( ) + 1 ; if ( $ this -> isManualCalculation ( ) && ( $ this -> getStepValue ( ) > 0 ) ) { $ stepValue = $ this -> getStepValue ( ) ; $ maxValue = ceil ( $ maxValue / $ stepValue ) * $ stepValue ; } return $ maxValue ; }
Returns max value of the slider .
44,058
private function isManualCalculation ( ) { $ result = false ; $ calculation = $ this -> _scopeConfig -> getValue ( PriceDataProvider :: XML_PATH_RANGE_CALCULATION , ScopeInterface :: SCOPE_STORE ) ; if ( $ calculation === PriceDataProvider :: RANGE_CALCULATION_MANUAL ) { $ result = true ; } return $ result ; }
Check if price interval is manually set in the configuration
44,059
private function getStepValue ( ) { $ value = $ this -> _scopeConfig -> getValue ( PriceDataProvider :: XML_PATH_RANGE_STEP , ScopeInterface :: SCOPE_STORE ) ; return ( int ) $ value ; }
Retrieve the value for Default Price Navigation Step .
44,060
private function isPopularQuery ( $ queryId , $ storeId ) { $ popularQueryIds = $ this -> queryCollection -> setPopularQueryFilter ( $ storeId ) -> setPageSize ( $ this -> getMaxCountCacheableSearchTerms ( $ storeId ) ) -> load ( ) -> getColumnValues ( 'query_id' ) ; return count ( array_intersect ( [ $ queryId ] , $ p...
Check if a query Id is among the popular query list for a given store .
44,061
private function cleanPopularSearchCache ( ) { try { $ this -> frontendCachePool -> get ( \ Magento \ PageCache \ Model \ Cache \ Type :: TYPE_IDENTIFIER ) -> clean ( \ Zend_Cache :: CLEANING_MODE_MATCHING_ANY_TAG , [ \ Smile \ ElasticsuiteCatalog \ Block \ CatalogSearch \ Result \ Cache :: POPULAR_SEARCH_CACHE_TAG ] )...
Cleanup popular searches cache tag .
44,062
public function buildAggregations ( ContainerConfigurationInterface $ containerConfig , array $ aggregations , array $ filters ) { $ buckets = [ ] ; foreach ( $ aggregations as $ aggParams ) { $ buckets [ ] = is_object ( $ aggParams ) ? $ aggParams : $ this -> buildAggregation ( $ containerConfig , $ filters , $ aggPar...
Build the list of buckets from the mapping .
44,063
private function buildAggregation ( ContainerConfigurationInterface $ containerConfig , $ filters , $ bucketParams ) { $ bucketType = $ bucketParams [ 'type' ] ; $ fieldName = $ bucketParams [ 'field' ] ?? $ bucketParams [ 'name' ] ; try { $ field = $ containerConfig -> getMapping ( ) -> getField ( $ fieldName ) ; $ bu...
Build a single aggregation .
44,064
private function createFilter ( ContainerConfigurationInterface $ containerConfig , array $ filters , $ currentPath = null ) { return $ this -> queryBuilder -> create ( $ containerConfig , $ filters , $ currentPath ) ; }
Create a QueryInterface for a filter using the query builder .
44,065
private function createPipelines ( $ bucketParams ) { if ( isset ( $ bucketParams [ 'pipelines' ] ) ) { foreach ( $ bucketParams [ 'pipelines' ] as & $ pipelineParams ) { $ pipelineType = $ pipelineParams [ 'type' ] ; $ pipelineParams = $ this -> pipelineFactory -> create ( $ pipelineType , $ pipelineParams ) ; } } ret...
Parse bucket params and create PipelineInterface instances
44,066
public function addScopeFilter ( $ scope , $ scopeCode , $ section ) { $ this -> addFieldToFilter ( 'scope' , $ scope ) ; $ this -> addFieldToFilter ( 'scope_code' , trim ( $ scopeCode ) ) ; $ this -> addFieldToFilter ( 'path' , [ 'like' => $ section . '/%' ] ) ; return $ this ; }
Add scope filter to collection
44,067
public function addField ( $ field , $ alias = null ) { if ( isset ( $ this -> addFieldStrategies [ $ field ] ) ) { $ this -> addFieldStrategies [ $ field ] -> addField ( $ this -> getCollection ( ) , $ field , $ alias ) ; return ; } parent :: addField ( $ field , $ alias ) ; }
Add field to select
44,068
protected function initData ( ) { parent :: initData ( ) ; array_walk ( $ this -> _data , function ( & $ indexConfigData , $ indexName ) { $ indexConfigData = $ this -> initIndexConfig ( $ indexName , $ indexConfigData ) ; } ) ; }
Init data for configuration .
44,069
private function initIndexConfig ( string $ indexName , array $ indexConfigData ) { $ types = [ ] ; foreach ( $ indexConfigData [ 'types' ] as $ typeName => $ typeConfigData ) { $ fields = $ this -> getMappingFields ( $ indexName , $ typeConfigData ) ; $ mapping = $ this -> mappingFactory -> create ( [ 'idFieldName' =>...
Init type mapping and fields from a index configuration array .
44,070
private function getMappingFields ( $ indexName , $ typeConfigData ) { \ Magento \ Framework \ Profiler :: start ( 'ES:Get dynamic fields config' ) ; $ fields = $ this -> getDynamicFields ( $ indexName , $ typeConfigData ) ; \ Magento \ Framework \ Profiler :: stop ( 'ES:Get dynamic fields config' ) ; foreach ( $ typeC...
Prepare mapping fields by merging static fields with dynamic ones .
44,071
private function getDynamicFields ( $ indexName , $ configData ) { $ fields = [ ] ; $ cacheId = implode ( '|' , [ $ this -> cacheId , $ indexName ] ) ; $ fieldsConfig = $ this -> cache -> load ( $ cacheId ) ; if ( false === $ fieldsConfig ) { $ legacyDataSources = [ $ indexName => $ configData [ 'datasources' ] ] ; $ r...
Get dynamic fields .
44,072
public function aroundGetFilterArray ( \ Magento \ Swatches \ Model \ ProductSubstitute $ productSubstitute , \ Closure $ proceed , array $ request ) { $ filterArray = $ proceed ( $ request ) ; $ attributeCodes = $ this -> eavConfig -> getEntityAttributeCodes ( \ Magento \ Catalog \ Model \ Product :: ENTITY ) ; foreac...
Build proper array for swatches rendering . Especially in product listing where values may come as label instead of option Ids .
44,073
private function addOptionsData ( array $ items ) { if ( $ this -> getAttributeModel ( ) -> getFacetSortOrder ( ) == BucketInterface :: SORT_ORDER_MANUAL ) { $ options = $ this -> getAttributeModel ( ) -> getFrontend ( ) -> getSelectOptions ( ) ; $ optionPosition = 0 ; if ( ! empty ( $ options ) ) { foreach ( $ options...
Resort items according option position defined in admin .
44,074
private function sortOptionsData ( array $ items ) { usort ( $ items , function ( $ item1 , $ item2 ) { if ( ! isset ( $ item1 [ 'adminSortIndex' ] ) or ! isset ( $ item2 [ 'adminSortIndex' ] ) ) { return 0 ; } return $ item1 [ 'adminSortIndex' ] <= $ item2 [ 'adminSortIndex' ] ? - 1 : 1 ; } ) ; return $ items ; }
Sort items by adminSortIndex key .
44,075
private function getForm ( ) { $ rule = $ this -> ruleFactory -> create ( ) ; if ( $ this -> getOptimizer ( ) && $ this -> getOptimizer ( ) -> getRuleCondition ( ) ) { $ rule = $ this -> getOptimizer ( ) -> getRuleCondition ( ) ; } $ form = $ this -> formFactory -> create ( ) ; $ form -> setHtmlId ( 'rule_condition' ) ...
Create the form containing the rule field .
44,076
public function convert ( $ source ) { $ source = $ this -> stripComments ( $ source ) ; $ requestNodes = $ source -> getElementsByTagName ( 'request' ) ; $ xpath = new \ DOMXPath ( $ source ) ; $ requests = [ ] ; foreach ( $ requestNodes as $ requestNode ) { $ simpleXmlNode = simplexml_import_dom ( $ requestNode ) ; $...
Convert config .
44,077
private function stripComments ( \ DOMDocument $ source ) { $ xpath = new \ DOMXPath ( $ source ) ; foreach ( $ xpath -> query ( '//comment()' ) as $ commentNode ) { $ commentNode -> parentNode -> removeChild ( $ commentNode ) ; } return $ source ; }
This method remove all comments of an XML document .
44,078
private function parseFilters ( \ DOMXPath $ xpath , \ DOMNode $ requestRootNode ) { $ filters = [ ] ; foreach ( $ xpath -> query ( self :: FILTERS_PATH , $ requestRootNode ) as $ filterNode ) { $ filters [ $ filterNode -> getAttribute ( 'name' ) ] = $ filterNode -> nodeValue ; } return $ filters ; }
Parse filters from request node configuration .
44,079
private function parseAggregations ( \ DOMXPath $ xpath , \ DOMNode $ rootNode ) { $ aggs = [ ] ; foreach ( $ xpath -> query ( self :: AGGREGATIONS_PATH , $ rootNode ) as $ aggNode ) { $ bucketName = $ aggNode -> getAttribute ( 'name' ) ; $ bucketConfig = [ ] ; foreach ( $ aggNode -> attributes as $ attribute ) { $ buc...
Parse aggregations from request node configuration .
44,080
private function parseAggregationsProviders ( \ DOMXPath $ xpath , \ DOMNode $ rootNode ) { $ providers = [ ] ; foreach ( $ xpath -> query ( self :: AGGREGATIONS_PROVIDERS_PATH , $ rootNode ) as $ providerNode ) { $ providers [ $ providerNode -> getAttribute ( 'name' ) ] = $ providerNode -> nodeValue ; } return $ provi...
Parse aggregations providers from request node configuration .
44,081
private function parseAggregationFilters ( \ DOMXPath $ xpath , \ DOMNode $ rootNode ) { $ filters = [ ] ; foreach ( $ xpath -> query ( self :: AGGREGATION_FILTERS_PATH , $ rootNode ) as $ filterNode ) { $ filters [ $ filterNode -> getAttribute ( 'name' ) ] = $ filterNode -> nodeValue ; } return $ filters ; }
Parse filters from a bucket .
44,082
private function parseMetrics ( \ DOMXPath $ xpath , \ DOMNode $ rootNode ) { $ metrics = [ ] ; foreach ( $ xpath -> query ( self :: METRICS_PATH , $ rootNode ) as $ metricNode ) { $ metric = [ ] ; foreach ( $ metricNode -> attributes as $ attribute ) { $ metric [ $ attribute -> name ] = $ attribute -> value ; } $ metr...
Parse metrics from a bucket .
44,083
private function parsePipelines ( \ DOMXPath $ xpath , \ DOMNode $ rootNode ) { $ pipelines = [ ] ; foreach ( $ xpath -> query ( self :: PIPELINES_PATH , $ rootNode ) as $ pipelineNode ) { $ pipeline = [ ] ; foreach ( $ pipelineNode -> attributes as $ attribute ) { $ pipeline [ $ attribute -> name ] = $ attribute -> va...
Parse pipelines from a bucket .
44,084
private function parsePipelineBucketsPath ( \ DOMXPath $ xpath , \ DOMNode $ pipelineNode ) { $ bucketsPath = null ; foreach ( $ xpath -> query ( self :: PIPELINE_COMPLEX_BUCKETS_PATH , $ pipelineNode ) as $ bucketsPathMappingNode ) { $ paramName = $ bucketsPathMappingNode -> getAttribute ( 'paramName' ) ; $ path = $ b...
Parse the buckets path of a pipeline aggregation .
44,085
private function getStockId ( $ websiteId ) { if ( ! isset ( $ this -> stockIdByWebsite [ $ websiteId ] ) ) { $ websiteCode = $ this -> storeManager -> getWebsite ( $ websiteId ) -> getCode ( ) ; $ stock = $ this -> stockResolver -> execute ( SalesChannelInterface :: TYPE_WEBSITE , $ websiteCode ) ; $ stockId = ( int )...
Retrieve stock_id by website
44,086
public function create ( $ bucketType , $ bucketParams ) { if ( ! isset ( $ this -> factories [ $ bucketType ] ) ) { throw new \ LogicException ( "No factory found for aggregation of type {$bucketType}" ) ; } return $ this -> factories [ $ bucketType ] -> create ( $ bucketParams ) ; }
Create a new bucket from it s type and params .
44,087
private function addAttributeData ( $ storeId , $ productIds , $ indexData = [ ] ) { foreach ( $ this -> attributeIdsByTable as $ backendTable => $ attributeIds ) { $ attributesData = $ this -> loadAttributesRawData ( $ storeId , $ productIds , $ backendTable , $ attributeIds ) ; foreach ( $ attributesData as $ row ) {...
Append attribute data to the index .
44,088
private function addChildData ( & $ parentData , $ childAttributes ) { $ authorizedChildAttributes = $ parentData [ 'children_attributes' ] ; $ addedChildAttributesData = array_filter ( $ childAttributes , function ( $ attributeCode ) use ( $ authorizedChildAttributes ) { return in_array ( $ attributeCode , $ authorize...
Append data of child products to the parent .
44,089
private function addRelationData ( & $ parentData , $ childAttributes , $ relation ) { $ childAttributeCodes = array_keys ( $ childAttributes ) ; $ parentAttributeCodes = array_keys ( $ parentData ) ; if ( ! isset ( $ parentData [ 'children_attributes' ] ) ) { $ parentData [ 'children_attributes' ] = [ 'indexed_attribu...
Append relation information to the index for composite products .
44,090
private function filterCompositeProducts ( $ indexData ) { $ compositeProductTypes = $ this -> resourceModel -> getCompositeTypes ( ) ; foreach ( $ indexData as $ productId => $ productData ) { $ isComposite = in_array ( $ productData [ 'type_id' ] , $ compositeProductTypes ) ; $ hasChildren = isset ( $ productData [ '...
Filter out composite product when no enabled children are attached .
44,091
private function addChildSku ( & $ parentData , $ relation ) { if ( isset ( $ parentData [ 'sku' ] ) && ! is_array ( $ parentData [ 'sku' ] ) ) { $ parentData [ 'sku' ] = [ $ parentData [ 'sku' ] ] ; } $ parentData [ 'sku' ] [ ] = $ relation [ 'sku' ] ; $ parentData [ 'sku' ] = array_unique ( $ parentData [ 'sku' ] ) ;...
Append SKU of children product to the parent product index data .
44,092
private function addIndexedAttribute ( & $ productIndexData , $ attribute ) { if ( ! isset ( $ productIndexData [ 'indexed_attributes' ] ) ) { $ productIndexData [ 'indexed_attributes' ] = [ ] ; } if ( isset ( $ productIndexData [ $ attribute -> getAttributeCode ( ) ] ) ) { $ productIndexData [ 'indexed_attributes' ] [...
Append an indexed attributes to indexed data of a given product .
44,093
public function toArray ( array $ keys = [ ] ) { $ data = parent :: toArray ( $ keys ) ; if ( in_array ( 'url' , $ keys ) || empty ( $ keys ) ) { $ data [ 'url' ] = $ this -> getUrl ( ) ; } if ( in_array ( 'is_selected' , $ keys ) || empty ( $ keys ) ) { $ data [ 'is_selected' ] = ( bool ) $ this -> getIsSelected ( ) ;...
Append url and is_selected computed fields to the result array .
44,094
private function getApplyValue ( ) { $ value = $ this -> getValue ( ) ; if ( is_array ( $ this -> getApplyFilterValue ( ) ) ) { $ value = $ this -> getApplyFilterValue ( ) ; } if ( is_array ( $ value ) && count ( $ value ) == 1 ) { $ value = current ( $ value ) ; } return $ value ; }
Return the value used to apply the filter .
44,095
private function getApplyQueryStringParams ( ) { $ qsParams = [ $ this -> getFilter ( ) -> getRequestVar ( ) => $ this -> getApplyValue ( ) , $ this -> _htmlPagerBlock -> getPageVarName ( ) => null , ] ; return $ qsParams ; }
Get query string params used to apply the filter .
44,096
private function rewriteBaseUrl ( $ qsParams ) { $ url = null ; if ( $ this -> getBaseUrl ( ) ) { $ baseUrlParts = explode ( '?' , $ this -> getBaseUrl ( ) ) ; $ qsParser = new \ Zend \ Stdlib \ Parameters ( ) ; $ qsParser -> fromArray ( $ qsParams ) ; if ( count ( $ baseUrlParts ) > 1 ) { $ qsParser -> fromString ( $ ...
Create the URL used to apply the filter from a existing URL .
44,097
public function create ( $ queryType , $ queryParams = [ ] ) { if ( ! isset ( $ this -> factories [ $ queryType ] ) ) { throw new \ LogicException ( "No factory found for query of type {$queryType}" ) ; } return $ this -> factories [ $ queryType ] -> create ( $ queryParams ) ; }
Create a query from it s type and params .
44,098
private function getSearchQueryId ( ) { $ queryId = null ; if ( $ this -> searchContext -> getCurrentSearchQuery ( ) ) { $ queryId = $ this -> searchContext -> getCurrentSearchQuery ( ) -> getId ( ) ; } return $ queryId ; }
Returns search query id .
44,099
public function getMappingFieldOptions ( AttributeInterface $ attribute ) { $ options = [ 'is_searchable' => $ attribute -> getIsSearchable ( ) , 'is_filterable' => $ attribute -> getIsFilterable ( ) || $ attribute -> getIsFilterableInSearch ( ) , 'search_weight' => $ attribute -> getSearchWeight ( ) , 'is_used_for_sor...
Parse attribute to get mapping field creation parameters .