Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Aggregations.php #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Model/Resolver/Aggregations.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class Aggregations extends AggregationsBase {
*/
public const CATEGORY_ID_CODE = 'category_id';

/**
* Code of the category uid in aggregations
*/
public const CATEGORY_UID_CODE = 'category_uid';

/**
* ID of the top level menu items
*/
Expand Down Expand Up @@ -129,7 +134,8 @@ protected function processPriceFilter(array $result): array {
protected function enhanceAttributes(array $result, $isSearch): array {
foreach ($result as $attr => $attrGroup) {
// Category ID is not a real attribute in Magento, so needs special handling
if($attrGroup['attribute_code'] == self::CATEGORY_ID_CODE){
if($attrGroup['attribute_code'] == self::CATEGORY_ID_CODE ||
$attrGroup['attribute_code'] == self::CATEGORY_UID_CODE){
$result[$attr]['is_boolean'] = false;
$result[$attr]['position'] = 0;
$result[$attr]['has_swatch'] = false;
Expand Down Expand Up @@ -167,7 +173,8 @@ protected function enhanceAttributes(array $result, $isSearch): array {

protected function removeNonTopLevelCategories(array $result) : array {
foreach ($result as $attr => $attrGroup){
if($attrGroup['attribute_code'] == self::CATEGORY_ID_CODE){
if($attrGroup['attribute_code'] == self::CATEGORY_ID_CODE ||
$attrGroup['attribute_code'] == self::CATEGORY_UID_CODE){
$newOptions = [];

foreach ($attrGroup['options'] as $option) {
Expand Down