openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.11k stars 718 forks source link

Variant incorrectly displaying unit name not display as in shopfront and backoffice #8553

Closed chezaorchard closed 2 years ago

chezaorchard commented 2 years ago

Description Product variants, where unit size=item, are displaying in all open shopfronts with only the unit name, not the full 'display as' which usually includes a number as well as descriptor.

Product variants, where unit size=item, are displaying in customer totals report with only the unit name, not the full 'display as'

Investigation:

Tested with user IDs: 2840 1927 153 2246 639

Expected Behavior All product variants should display in shopfronts and reports with complete 'display as' value

Actual Behaviour Product variants are incorrectly displaying in shopfronts and some reports as 'unit name' only

Steps to Reproduce Navigate to open shop Scroll down to product variant where size=item Observe variant is incorrectly displaying with 'unit name' only

Log in as superadmin (User ID 2840) Run customer totals report for current order cycle Observe column G incorrectly displays 'unit name' only

Long in as customer (User ID 2840) Run customer totals report for current order cycle Observe column G incorrectly displays 'unit name' only

Check with User ID 2840 via phone - they downloaded the report yesterday evening (approx Australian time 10pm, Wed Dec) and the report did contact the correct 'display as' at that time.

Screenshot

Screen Shot 2021-12-02 at 4 06 58 pm Screen Shot 2021-12-02 at 4 09 01 pm Screen Shot 2021-12-02 at 4 25 19 pm Screen Shot 2021-12-02 at 4 25 33 pm Screen Shot 2021-12-02 at 4 33 51 pm Screen Shot 2021-12-02 at 4 33 19 pm

Severity

bug-s2: a non-critical feature is broken, no workaround

Your Environment

lin-d-hop commented 2 years ago

Is this related to #8500?

RachL commented 2 years ago

@lin-d-hop Judging by Chez comment on slack it seems #8500 introduced this problem :(

lin-d-hop commented 2 years ago

@apricot12 Can we assign to you in this case? @openfoodfoundation/testers Let's also make sure we take both cases into account during testing.

apricot12 commented 2 years ago

@lin-d-hop Yes, I'll look at it immediately.

jibees commented 2 years ago

@openfoodfoundation/testers Let's also make sure we take both cases into account during testing.

Could we also create an automatic test for this?

RonellaG commented 2 years ago

@apricot12 @jibees @lin-d-hop @RachL We've started to have more hubs enquire about this issue. This is impacting their shopfront listings as well as their ability to generate packing reports. What is the status of this bug and how soon can it be resolved? Given it impacts our hubs sales and operations quite a lot can it please be labelled S1?

chezaorchard commented 2 years ago

User ID 286, a bulk food hub, are experiencing this issue with their current order cycle: "The pricing for e.g. coconut cream is $3.25/can if bought by the can or in 6's but $2.55/can if ordered in 12's. However the shopper will not realise how many cans they are buying as the number has now disappeared."

apricot12 commented 2 years ago

@apricot12 @jibees @lin-d-hop @RachL We've started to have more hubs enquire about this issue. This is impacting their shopfront listings as well as their ability to generate packing reports. What is the status of this bug and how soon can it be resolved? Given it impacts our hubs sales and operations quite a lot can it please be labelled S1?

Hey, It should be up for code review by today. I'll try to speed it up as much as possible :)

apricot12 commented 2 years ago

@chezaorchard @RonellaG I've just put up a PR that fixes this issue. Now it's just a matter of going through the review and testing process and getting it into this weeks release.

Matt-Yorkley commented 2 years ago

Hey :wave:, I've just been looking through this and the other related issues (#8495) and recent changes (#8500).

It's a tricky one! The way these different values are saved is really complex in terms of the datamodel, and the code that handles it is quite arcane (the VariantUnits::VariantAndLineItemNaming service). The tricky part is that even small changes in that service can potentially have lots of different effects all throughout the codebase, and it's almost impossible to predict what they'll be.

I think I would suggest maybe reverting the changes in #8500, and then trying to re-assess how to solve the original issue #8495 by making some changes in the view files that handle displaying products in the shopfront, eg:

apricot12 commented 2 years ago

@Matt-Yorkley I was wondering the same thing. I wanted to try implementing some view logic to fix this, but I wasnt sure if it was the right thing to do. It seemed urgent too so I just went with a hacky fix.

Matt-Yorkley commented 2 years ago

I wasnt sure if it was the right thing to do.

Fair enough! I'm personally terrified of touching that service :sweat_smile: It's really difficult to work with.

mkllnk commented 2 years ago

It sounds like a good idea to replace its use bit by bit then. For another PR I went through the code just to find out which database fields it was using and it which order and that was an essay already.

I just reverted #8500 on au-prod because it's causing huge problems for our enterprises here. We should probably do that in master and then any further change needs to first add a spec for this issue (shopfront and reports were affected) and then find a better way of solving the original issue.

filipefurtad0 commented 2 years ago

In principle this bug won't be occurring anymore after this weeks release, as it was introduced by #8500 - I'll leave it as a production test, as a double check.

filipefurtad0 commented 2 years ago

Customer totals report displays the correct #display_as name, after reverting the aforementioned PR, closing:

image