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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ytsurk created an issue. See original summary.

ytsurk’s picture

Issue summary: View changes
ericshell’s picture

I 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.

Lendude’s picture

Here we go, fix and test

Lendude’s picture

bit of a clean up since the setup isn't needed since we are not looking for valid results here.

Cheviot’s picture

Same 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?

Lendude’s picture

Is this covered in the test patch?

It should be, using the filter via a relationship or directly doesn't matter for config.

Cheviot’s picture

Is 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.

jegaudin’s picture

Hello, Have been facing the same issue, thank you for the workaround ytsurk.

Cheviot’s picture

Using 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?

Lendude’s picture

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?

Because 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.

Cheviot’s picture

@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).

Lendude’s picture

+++ b/modules/product/config/schema/commerce_product.schema.yml
@@ -93,3 +93,7 @@ action.configuration.commerce_publish_product:
+views.filter.commerce_product_attribute_value:
+  type: views.filter.in_operator
+  label: 'Product attribute filter'

Well the patch in comment #5 should fix it. The above code is really all that should be needed, the rest is just test coverage.

bojanz’s picture

Issue tags: -Configuration schema

The patch looks great, and I love the test.

Lendude, please ping me on Slack the next time I miss a fix like this.

  • bojanz committed 3990b9b on 8.x-2.x authored by Lendude
    Issue #2879869 by Lendude, bojanz: Fatal error when trying to save a...
bojanz’s picture

Status: Needs review » Fixed

Merged-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!

Cheviot’s picture

@bojanz patch in #5 works as a charm! Now I can save the view! Thanks so much for this!!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.