Search code examples
shopwareshopware6

How to add custom field to the admin search in Shopware 6?


How to add product custom field to the search in the admin?

I couldn't find anything in Shopware documentation, only for custom entities.


Solution

  • I don't think you can add custom fields in the search preferences of your profile yet. You can however add fields by altering the corresponding entry in the table user_config.

    For the entry to exist in the database you'll have to first make some changes in the search preferences of your profile.

    Then find the entry for the correct user id in user_config. The column value contains the search preferences as json.

    Edit that json to your liking, for example to add a custom field of a product to the searchable fields:

    [
        // ...
        {
            // ...
            "product": {
                // ...
                "customFields": {
                    "the_technical_name_of_a_custom_field": {
                        "_score": 500,
                        "_searchable": true
                    }
                },
                // ...
            },
            // ...
        },
        // ...
    ]