shopware / shopware

Shopware 6 is an open commerce platform based on Symfony Framework and Vue and supported by a worldwide community and more than 1.500 community extensions
https://shopware.com
MIT License
2.81k stars 1.02k forks source link

Incorrect ElasticSearch mapping for JSON CustomFields #4290

Closed shopwareBot closed 3 weeks ago

shopwareBot commented 2 months ago

Description:

A CustomField of "type" => CustomFieldTypes::JSON will be mapped to

[
    'type' => 'object',
    'dynamic' => true,
]

If the custom field is populated by a sw-entity-multi-id-select component, the fields value is, in fact, of type array (equally encodable to JSON).

The resulting error is:

Object mapping for [customFields.dummy_field] tried to parse field [null] as object, but found a concrete value"

Environment: Shopware 6.6.1 with OpenSearch 2.13.0

Steps to reproduce:

  1. Install Shopware and setup OpenSearch in the specified versions
  2. Create a demo plugin with a custom field using the following configuration:
    [
            'id' => md5('plugin_set'),
            'name' => 'cusom_set,
            'config' => [
                'label' => [
                    'de-DE' => 'Set',
                    'en-GB' => 'Set'
                ],
                'translated' => true
            ],
            'customFields' => [
                [
                    'id' => md5('plugin_field'),
                    'name' => 'custom_field',
                    'type' => CustomFieldTypes::JSON,
                    'config' => [
                        'type' => 'select',
                        'componentName' => 'sw-entity-multi-id-select',
                        'customFieldType' => CustomFieldTypes::JSON,
                        'entity' => 'product_manufacturer',
                        'value' => 'id',
                        'customFieldPosition' => 1
                    ],
                ],
            ],
            'relations' => [
                [
                    'id' => md5('custom_relation'),
                    'entityName' => 'product'
                ]
            ]
        ];
  3. Install the demo plugin
  4. Create a custom field of type sw-entity-multi-id-select on the product entity
  5. Create a product and save a selection to the custom field

Expected result:

Product saves correctly and quietly.

Actual result:

Object mapping for [customFields.dummy_field] tried to parse field [null] as object, but found a concrete value"

Relevant parts of shopware code:

https://github.com/shopware/elasticsearch/blob/77159dc852765e6699622c1dc4eedfdc3ff3d8c9/Product/CustomFieldUpdater.php#L93

shopware-issue-bot[bot] commented 2 months ago

We found the following existing issues which may help or are related to your topic:

shopwareBot commented 2 months ago

[public] Automated response: This issue is linked to the internal issue https://shopware.atlassian.net/browse/NEXT-35565.

[created from NEXT-35565, comment 486436]