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

[Category Filtering]:Complete Category Filtering Feature w/ GQL #1432

Closed
3 of 6 tasks
awilcoxa opened this issue Jul 11, 2019 · 8 comments
Closed
3 of 6 tasks

[Category Filtering]:Complete Category Filtering Feature w/ GQL #1432

awilcoxa opened this issue Jul 11, 2019 · 8 comments

Comments

@awilcoxa
Copy link

awilcoxa commented Jul 11, 2019

In #361 we completed the UI requirements for Category filtering but at the time we were blocked on completion due to GQL dependency. That GQL requirement is now completed and so additional effort is required to connect the UI to the backing GQL endpoint.

GQL dependency: magento/graphql-ce#259

Describe the solution you'd like
Category Filters are now complete and available in Venia

Please let us know what packages this feature is in regards to:

  • venia-concept
  • pwa-buildpack
  • peregrine
  • pwa-devdocs
  • upward-js
  • upward-spec
@sirugh
Copy link
Contributor

sirugh commented Jul 12, 2019

@awilcoxa As far as I can tell we are still restricted to filtering products based on this schema: ProductFilterInput. If there is another way we are supposed to filter, I'd like to learn about it.

For context, we currently filter by category_id, which is an attribute on ProductFilterInput:

products(
  filter: { category_id: { eq: "11" } }
)

Assuming we are wanting to filter using that filter variable, I would expect to be able to expand the object similar to the code below, except that we aren't because the filter object is pre-defined to be the ProductFilterInput type.

products(
  filter: { 
    category_id: { eq: "11" }
    fashion_material: { eq: "39" } # 39 == cotton, but this fails because fashion_material is not a property of ProductFilterInput
  }
)

It's also possible I'm not even approaching this the right way so I'm just documenting my findings so far for my own sake. One thing I found interesting is that you have to provide a type for everything in GQL. I'm not sure how we are going to handle the potentially large number of random attributes/props our clients will want to filter by. Do we dynamically generate the schema for products such as ConfigurableProduct?

@sirugh
Copy link
Contributor

sirugh commented Jul 12, 2019

Ah, looks like this is related: magento/graphql-ce#500 which should be released in 2.3.3.

@awilcoxa
Copy link
Author

https://devdocs.magento.com/guides/v2.3/rest/performing-searches.html

Needs additional GQL research to determine if we are blocked.

@zetlen
Copy link
Contributor

zetlen commented Jul 29, 2019

Posted a comment in magento/graphql-ce#500 suggesting an alternate input structure that the GQL team might find it easier to implement. They'd have to weigh in.

@sirugh sirugh removed their assignment Jul 30, 2019
@TomashKhamlai
Copy link

🔔 magento/graphql-ce#500

@awilcoxa awilcoxa added the help wanted Eligible for community contribution. label Feb 3, 2020
@sirugh sirugh self-assigned this Feb 7, 2020
@sirugh
Copy link
Contributor

sirugh commented Feb 11, 2020

  • Custom attributes will get added to the schema after you flush the config cache.

  • ProductAttributeFilterInput on 2.3.4:
    https://i.gyazo.com/869d6bddc4840780426879282900f130.png

  • When we click "Apply Filters" the filter state is updated locally. In the Apply
    callback we can access that state which will be keyed filter name and value.

  • We should be able to pass an input object for filter constructed from the state.

filterState.get('fashion_style')

// outut
// {
//    title: 'Above Knee',
//    value: '16432'
// }

If we want to filter for "Bottoms" and "Above Knee", we would query:

{
  products(filter: {category_id: {eq: "28"}, fashion_style: {eq: "16432"}}) {
    total_count
    items {
      name
      sku
    }
  }
}

If we wanted to filter for "Buttoms and multiple styles, we would query:

{
  products(filter: {category_id: {eq: "28"}, fashion_style: {in: ["16432", "some-other-style-id"}}) {
    total_count
    items {
      name
      sku
    }
  }
}

@awilcoxa awilcoxa removed the help wanted Eligible for community contribution. label Mar 2, 2020
@awilcoxa
Copy link
Author

awilcoxa commented Mar 2, 2020

Currently in progress, removing help wanted label

@sirugh sirugh removed their assignment Feb 23, 2021
@sirugh
Copy link
Contributor

sirugh commented Feb 23, 2021

Category filtering is operational in the search page.

@sirugh sirugh closed this as completed Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants