shopware custom admin config component doesn't save sales channel id

Viewed 54

For a shopware 6 plugin , in config.xml I have a custom component

<card>
    <title>My Plugin</title>
    <title lang="de-DE">My Plugin</title>
    <component name="config-component">
        <name>configComponent</name>
    </component>
</card>

In the twig of this component i have a simple field

<sw-text-field :label="Test" size="medium" required />

I saw that for components, if i want to change the sales channel and save the data, the sales channel id is not saved in the system_config table for that text field.

What can i do so my inputs from components be dependent on sales channels? Thank you

1 Answers

The following component and template should work as intended.

import template from './config-component.html.twig';

const { Component } = Shopware;

Component.register('config-component', {
    template,

    props: {
        value: {
            required: true,
        }
    },

    methods: {
        onChange(value) {
            this.$emit('change', value || '');
        },

        onInput(value) {
            this.$emit('input', value);
        }
    }
});
<sw-text-field
    v-model="value"
    label="Test"
    size="medium"
    required
    @input="onInput"
    @change="onChange"
/>
Related