Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
There is an issue with filtering by price on views.
Use case :
You want to create a view which filters orders where order total price is greater then (or less then or similar) some amount.
Providing patch that fixes this issue.
Also screenshots of the issue with and without patch
Comment | File | Size | Author |
---|---|---|---|
#4 | 2882374-4.patch | 426 bytes | drugan |
#3 | 2882374-3.patch | 3.66 KB | Lendude |
commerce_price_filter.patch | 916 bytes | xSDx | |
with_patch.png | 33.95 KB | xSDx | |
without_patch.png | 31.85 KB | xSDx |
Comments
Comment #2
xSDx CreditAttribution: xSDx at Websolutions Agency commentedComment #3
LendudeThis is the underlying issue here, #2509986: EntityViewsData is broken for fields with 'numeric' columns, such as decimal fields (DecimalItem), Price uses a decimal field which Views currently handles wrong.
The Field API price fields work fine, it's just base fields that have a problem. So any entity that has a price base field needs to update its views data.
Here is a little something I tried. But really, this needs to be fixed upstream (which is now on my todo list).
Comment #4
drugan CreditAttribution: drugan as a volunteer commentedThe #3 works great but would it be more appropriate for a temporary solution just to alter views data.
...keeping in mind that #2509986: EntityViewsData is broken for fields with 'numeric' columns, such as decimal fields (DecimalItem) will be fixed some day in any case.
Comment #5
Leagnus CreditAttribution: Leagnus commented#4 works fine on 8.5.x-dev
Comment #6
bojanz CreditAttribution: bojanz at Centarro commentedWe need #3 because it fixes all price fields on all entity types.
#4 covers only a single price field on variations.
I'd argue that "Drupal\commerce_price\PriceBaseFieldViewsData" is a bit odd though, I'd introduce a CommerceViewsData class instead, for this and other future workarounds.
Comment #7
s_leu CreditAttribution: s_leu at Station commented#3 works for me for the timebeing, not sure whether it's maybe only until #2509986: EntityViewsData is broken for fields with 'numeric' columns, such as decimal fields (DecimalItem) is fixed though.
Comment #8
bojanz CreditAttribution: bojanz at Centarro commentedNeed to address #6, and to sync the signature of processViewsDataForCommercePrice() with Drupal 8.5.0
Comment #9
bojanz CreditAttribution: bojanz at Centarro commentedComment #11
bojanz CreditAttribution: bojanz at Centarro commentedDone. Made all entity types use the new CommerceEntityViewsData cause I'm sure we'll be adding other workarounds there as well.