Skip to content

Commit

Permalink
Merge pull request #886 from Hlavtox/pass-attribute
Browse files Browse the repository at this point in the history
Pass attribute information with the results
  • Loading branch information
Hlavtox authored Aug 1, 2023
2 parents b8f58d9 + cc30d67 commit d6544e8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Product/SearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ public function runQuery(
// Init the search with the initial population associated with the current filters
$facetedSearch->initSearch($facetedSearchFilters);

// Request combination IDs if we have some attributes to search by.
// If not, we won't use this to let the core select the default combination.
if ($this->shouldPassCombinationIds($facetedSearchFilters)) {
$facetedSearch->getSearchAdapter()->getInitialPopulation()->addSelectField('id_product_attribute');
$facetedSearch->getSearchAdapter()->addSelectField('id_product_attribute');
}

// Load the product searcher, it gets the Adapter through Search object
$filterProductSearch = new Filters\Products($facetedSearch);

Expand Down Expand Up @@ -586,4 +593,16 @@ private function updateQueryString(array $extraParams = [])

return $url . ($queryString ? "?$queryString" : '');
}

/**
* Checks if we should return information about combinations to the core
*
* @param array $facetedSearchFilters filters passed in the query and parsed by our module
*
* @return bool if should add attributes to the select
*/
private function shouldPassCombinationIds(array $facetedSearchFilters)
{
return !empty($facetedSearchFilters['id_attribute_group']);
}
}

0 comments on commit d6544e8

Please sign in to comment.