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

Support filterBy in hierarchy extra results #656

Open
novoj opened this issue Aug 30, 2024 · 0 comments
Open

Support filterBy in hierarchy extra results #656

novoj opened this issue Aug 30, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@novoj
Copy link
Collaborator

novoj commented Aug 30, 2024

When developers create menus, they often want to exclude some categories from listed hierarchy. Inuitive approach would be:

query megamenu(
  $locale: CatalogLocale
  $currency: CatalogCurrency
  $priceType: QueryPriceMode = WITH_TAX
  $priceInPriceLists: [String!] = []
  $stocks: [String!] = []
  $productType: [String!] = ["BASIC", "SET", "MASTER"]
  $distance: Int = 3
) {
  queryProduct(
    filterBy: {
      entityLocaleEquals: $locale
      priceInCurrency: $currency
      priceInPriceLists: $priceInPriceLists
      priceValidInNow: true
      attributeStatusEquals: "ACTIVE"
      attributeProductTypeInSet: $productType
      referenceStockVisibilitiesHaving: {
        entityHaving: { attributeCodeInSet: $stocks }
      }
    }
    require: { priceType: $priceType }
  ) {
    extraResults {
      hierarchy {
        categories(
          emptyHierarchicalEntityBehaviour: REMOVE_EMPTY        
          # this could have filtering constraint
          filterBy: { attributeVisibilityEquals: "VISIBLE" }
          orderBy: { attributeOrderNatural: ASC }
        ) {
          fromRoot(stopAt: { distance: $distance }) {
            level
            entity {
              primaryKey
              parentPrimaryKey
              attributes {
                name
                url
              }
              representedCategory {
                referencedEntity {
                  attributes {
                    url
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

But actually they need to do this query which is not so intuitive to the developers.

When both these filters are defined, they needs to be combined using AND relation.

@novoj novoj self-assigned this Aug 30, 2024
@novoj novoj added the enhancement New feature or request label Aug 30, 2024
@novoj novoj added this to the Beta milestone Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant