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

Filtering product by supplier property breaks when enterprise has custom sorting by category set #12656

Closed
mkllnk opened this issue Jul 10, 2024 · 4 comments · Fixed by #12704
Assignees
Labels
bug-s3 The bug is stopping a critical or non-critical feature but there is a usable workaround. bugsnag

Comments

@mkllnk
Copy link
Member

mkllnk commented Jul 10, 2024

Description

When looking at a shop, customer have the ability to filter products by product category, supplier property or product property using the the "tag" under "filter by" on the left hand side of the page.

In the specific scenario where a supplier as set a custom sorting by category, filtering by supplier property doesn't work. When clicking on a supplier property, the "tag" will be selected, but the filtering won't happen and the loading products spinner never disappear.
The bug can be reproduced here : https://staging.openfoodnetwork.org.au/noname-hub/shop when filtering by "Free Range"

This was introduced by the Product refactor

Expected Behavior

Only product inheriting "Free Range" supplier property should be displayed

filter_bug_expectedl

Actual Behaviour

All product are shown, no filtering is happening and Loading products spinner doesn't disappear. There is a request returning a 422 error (see bugsnag below)

filter_bug_actual

Steps to Reproduce

As a enterprise manager

  1. Go to the shop setting, and select "shop preferences" on the left hand side menu
  2. Set "Display ordering in shopfront" to "By category" and select one or more categories and save change
  3. Now select "Properites" on the left hand side menu
  4. Add a property
  5. Go to the "Products" page and choose a product
  6. Add a property to the product and tick "Inherit properties from ", and update

As a customer

  1. Navigate to the shop page
    2.Try to filter by the supplier property added above -> filtering doesn't work

Error in Coopcircuits

ActiveRecord::StatementInvalid in api/v0/order_cycles#products
PG::UndefinedColumn: ERROR: column first_variant.supplier_id does not exist
LINE 4: ...t.product_id JOIN enterprises ON enterprises.id = first_vari...
^

View on Bugsnag

Another one on AU prod:
https://app.bugsnag.com/yaycode/openfoodnetwork-aus/errors/668cc120963f0b000858abbf?event_id=668dd06e00efe4c55a620000&i=sk&m=nw

Stacktrace

app/services/products_renderer.rb:91 - filter
app/services/products_renderer.rb:41 - products
app/services/products_renderer.rb:20 - products_json
app/controllers/api/v0/order_cycles_controller.rb:26 - products

View full stacktrace

Created by Coopcircuits Admin via Bugsnag

Workaround

Can still browse product it just less convenient to not be able to filter.

Severity

bug-s3: a feature is broken but there is a workaround

@mkllnk mkllnk added the bugsnag label Jul 10, 2024
@rioug rioug added the bug-s3 The bug is stopping a critical or non-critical feature but there is a usable workaround. label Jul 10, 2024
@rioug rioug changed the title ActiveRecord::StatementInvalid in api/v0/order_cycles#products Filtering product by supplier property breaks when enterprise has custom sorting by category set Jul 10, 2024
@cyrillefr
Copy link
Contributor

Hello @mkllnk , @filipefurtad0 , @sigmundpetersen , @RachL

May I work on this issue ?
(Sorry for the multiple ping, but I guess some of you might enjoy well deserved holidays and I do not know which account I should ping).

@RachL
Copy link
Contributor

RachL commented Jul 22, 2024

@cyrillefr FYI you can use groups @openfoodfoundation/core-devs for devs and @openfoodfoundation/train-drivers-product-owners for PO in doubt ;)

Yes please go ahead I will assign you, many thanks!

@rioug
Copy link
Collaborator

rioug commented Jul 22, 2024

@cyrillefr this one is tricky I think. Let me know if you need some help.

@cyrillefr
Copy link
Contributor

Hello @rioug ,

Thanks for your help.
I have just uploaded some code and indeed I would need your feedback.(I will made another comment on PR).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-s3 The bug is stopping a critical or non-critical feature but there is a usable workaround. bugsnag
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants