Problem/Motivation
When using a filter in a View that is not 'string' based (thus fe. an attribute), saving the view gives an "Error" page with message "InvalidArgumentException: The configuration property display.default.display_options.filters.attribute_name_target_id.value.1 doesn't exist. in Drupal\Core\Config\Schema\ArrayElement->get() (line 74 of core/lib/Drupal/Core/Config/Schema/ArrayElement.php).".
See the related core issue: #2369119: Fatal error when trying to save a View with grouped filters using other than string values
Proposed resolution
I guess the proper resolution would be do define the views_filter_group_item in schema.yml. See this geolocation issue: #2870523: Grouped filter in Views display results in 'configuration property doesn't exist' InvalidArgumentException
Something like:
views.filter.group_item.product_attribute:
type: views_filter_group_item
mapping:
value:
type: views.filter_value.numeric
Steps to reproduce
Create a product variation view with an attribute filter.
Saving the view gives an "Error" page with the mentioned message.
Workaround
A not-so-elegant (nor multilingual) workaround is using relations ... add the attribute as relation and then check the attribute name string value.
Comment | File | Size | Author |
---|---|---|---|
#5 | 2879869-5.patch | 7.88 KB | Lendude |
| |||
#5 | interdiff-2879869-4-5.txt | 1.11 KB | Lendude |
#4 | 2879869-4.patch | 8.39 KB | Lendude |
#4 | 2879869-4-TEST_ONLY.patch | 7.78 KB | Lendude |
Comments
Comment #2
ytsurkComment #3
ericshell CreditAttribution: ericshell as a volunteer commentedI am getting the same exact error when using an indexed term reference field (Product variation datasource) from Search API as a (using the Search API term handlers module). Tried all patches from the related issue without luck. Commenting just to follow and potentially add more helpful info.
Comment #4
LendudeHere we go, fix and test
Comment #5
Lendudebit of a clean up since the setup isn't needed since we are not looking for valid results here.
Comment #6
Cheviot CreditAttribution: Cheviot as a volunteer commentedSame here as in #3 using ecommerce - it happens in a Views with "Relationships variations: Product variation" and then using Filter criteria (variations: Product variation) Product variation: Product (= model)
The error is then "The website encountered an unexpected error. Please try again later." The log shows
InvalidArgumentException: The configuration property display.default.display_options.filters.attribute_product_target_id.value.1 doesn't exist. in Drupal\Core\Config\Schema\ArrayElement->get() (line 74 of /Library/WebServer/Documents/ps/web/core/lib/Drupal/Core/Config/Schema/ArrayElement.php).
Is this covered in the test patch? Can I give any more info to support you in finding a solution?
Comment #7
LendudeIt should be, using the filter via a relationship or directly doesn't matter for config.
Comment #8
Cheviot CreditAttribution: Cheviot as a volunteer commentedIs the patch part of drupal/commerce_stock 1.x-dev ba93162 ?
I still have no any solution found how to filter in a view using the product attributes (view filer criteria), it always leads to the same error.
Yet the values are visible when I add the variation field as Product: Variations (Variations) with 'add to cart form'.
The variation attributes values are passed on from the SQL query but cannot be used to filter on. How should it work?
I use drupal commerce / drupal 8 all the latest version.
Comment #9
jegaudin CreditAttribution: jegaudin commentedHello, Have been facing the same issue, thank you for the workaround ytsurk.
Comment #10
Cheviot CreditAttribution: Cheviot as a volunteer commentedUsing an attribute in the view to filter still throws the a white screen error (Drupal 8.5.0).
I'm using the ecommerce modules (8.x-2.5)
This problem occurs in:
- group-by as well without group-by
- shown as a product or as fields even in the most simple setup (views format tab)
Setting the filter to 'all' (option to select from the range):
InvalidArgumentException: The configuration property display.default.display_options.filters.attribute_product_target_id.value.all doesn't exist. in Drupal\Core\Config\Schema\ArrayElement->get() (line 76 .... /ArrayElement.php).
I can select and get a correct filter result in the views preview pane. Only saving the view is then impossible.
I understood that the attribute is parsed as a non-string to views causing this. Why is it possible to use the non-string and get a views-preview-result while this non-string cannot be used to save the view?
Should the attribute be parsed by string - and hence should be raised as an attribute/taxonomy issue - or should views be adapted to accept non-strings and be seen an views issue?
This needs to be solved in a more fundamental and overall design rather than reacting with case-by-case patching as I have seen in other issue numbers. Was is the core design that should be followed here by the added non-core modules?
Comment #11
LendudeBecause the error comes from having invalid configuration, and the configuration isn't set or tested when you use preview, only once you save.
And the preview works because the config is functional, it just doesn't match the declared config schema. That is why we only need to update the schema and no functional changes are needed to make this work.
Comment #12
Cheviot CreditAttribution: Cheviot as a volunteer commented@Lendude - That clarifies it a bit. Where should I or anyone start? This is rather new to me, I never had anything to do with schema's and these specific configurations.
I break it down:
1) where should I look for the configuration and then,
2) how do I compare that against the schema (which one, where?).
Maybe I can find a solution for this (a wee maybe as we say in geordie land, I have never done this before).
Comment #13
LendudeWell the patch in comment #5 should fix it. The above code is really all that should be needed, the rest is just test coverage.
Comment #14
bojanz CreditAttribution: bojanz at Centarro commentedThe patch looks great, and I love the test.
Lendude, please ping me on Slack the next time I miss a fix like this.
Comment #16
bojanz CreditAttribution: bojanz at Centarro commentedMerged-in a cleanup that creates a single commerce_product_test module (out of the existing one and the one added by #5), and tweaked view naming.
Thanks!
Comment #17
Cheviot CreditAttribution: Cheviot as a volunteer commented@bojanz patch in #5 works as a charm! Now I can save the view! Thanks so much for this!!