在 Shopware 6 中为自定义字段添加自定义实体类型

Add custom entity type for custom field in Shopware 6

在 Shopware 6.4.0.0 中,可以添加基于实体的自定义字段。

实体类型列表有限:

是否可以轻松添加其他实体类型,例如可用产品属性列表?

编辑 https://github.com/shopware/platform/blob/trunk/src/Administration/Resources/app/administration/src/module/sw-settings-custom-field/component/sw-custom-field-type-entity/index.js#L9

加点就够了

            {
                label: "Product Property Group",
                value: 'property_group'
            }

到select

https://github.com/shopware/platform/blob/trunk/src/Administration/Resources/app/administration/src/module/sw-settings-custom-field/component/sw-custom-field-type-entity/index.js#L9

然后可以创建一个自定义字段,让我们选择产品属性。

接下来我们必须使这个更改持久化。

https://developer.shopware.com/docs/guides/plugins/plugins/administration/customizing-components

Component.override('sw-custom-field-type-entity', {
    computed: {
    entityTypes() {
        const types = this.$super('entityTypes');

        types.push(
            {
                label: 'Product Property Group',
                value: 'property_group'
            }
        );

        return types;
    }
    }
});