- Issue created by @m.stenta
- πΊπΈUnited States m.stenta
Ah OK... I found an important clue:
In the context of
QuantityEventSubscriber::quantityPresave()
,$event->quantity->get('unit_price')->fraction
returns the old value, and$event->quantity->get('unit_price')->getValue()
returns the new value.This must have something to do with how/when the Fraction module sets the
->fraction
property. Maybe it isn't being updated before this event subscriber runs. - @mstenta opened merge request.
- Status changed to Needs review
over 1 year ago 12:36am 30 March 2023 - πΊπΈUnited States m.stenta
I dug in with XDebug and this is what I found...
FractionProperty::getValue()
runs first, but there doesn't seem to be any way to get the new value from within that method's context.QuantityEventSubscriber::quantityPresave()
runs afterwards, and$event->quantity->get('unit_price')->fraction
still has the old value, but$event->quantity->get('unit_price')->getValue()
has the new value.The merge request I opens doesn't dig any deeper than that. It simply refactors the event listener logic to use
getValue()
instead offraction
.I'd prefer to use
fraction
, at least conceptually. From a DX perspective it feels like I should be able to. I may continue digging into that... but the MR I opened fixes the issue by working around that, so it's worth considering anyway. - Status changed to Postponed
over 1 year ago 5:34pm 5 April 2023 - πΊπΈUnited States m.stenta
I'd prefer to use
fraction
, at least conceptually. From a DX perspective it feels like I should be able to. I may continue digging into that...I opened an upstream issue in the Fraction module for this: π Update fraction and decimal properties via setValue() Fixed
I have a working solution there, so once that gets merged we can update this module to require the new version of Fraction and close this.
- πΊπΈUnited States m.stenta
This was fixed upstream in Fraction 2.3.0. This module now requires that version as a minimum to fix this issue.
- Status changed to Fixed
over 1 year ago 7:34pm 19 April 2023 Automatically closed - issue fixed for 2 weeks with no activity.