2

这是这个问题的延续。我仍在学习如何使用 Shopware,我的文件中的文件结构几乎相同。

我想在管理员的产品表单中添加 3 个字段,到目前为止,我已经在产品表上创建了表和额外的列(虽然不确定我是否真的需要这个)。当我硬编码时,它将字符串保存到我的新表中,实体似乎已被读取,当我搜索存储库时,我得到了正确的扩展扩展名:

return this.extensionRepository.search(this.extensionCriteria)
            .then((extension) => {
                console.log(extension);
            });

但是我真的不明白如何保存该值并将其读出,因为当我获得带有值的扩展名时,我无法将值放在输入字段中,而当我保存它时却没有,因为我得到了这个error TypeError: e.getEntityName is not a function,我猜它来自 sw-inherit.wrapper/index.js 文件。

我想在管理员中使用产品页面的可交付性部分中的字段。基本上用浮动替换 3 个输入,因为商店将出售织物,而这以米为单位,如 0.2 米。

所以我的树枝模板看起来像这样:

{% block sw_product_deliverability_form_min_purchase_field %}
<sw-inherit-wrapper
    v-if="showModeSetting"
    v-model="extension.customMinPurchase"
    class="sw-product-deliverability__min-purchase"
    :has-parent="!!parentProduct.id"
    :inherited-value="extension.customMinPurchase"
>
    <template #content="props">

        <sw-field
            type="number"
            :map-inheritance="props"
            number-type="float"
            :min="0"
            :error="productMinPurchaseError"
            :label="$tc('sw-product.settingsForm.labelMinPurchase')"
            :placeholder="$tc('sw-product.settingsForm.placeholderMinPurchase')"
            :disabled="props.isInherited || !allowEdit"
            :value="props.currentValue"
            @change="props.updateCurrentValue"
        />

    </template>
</sw-inherit-wrapper>

{% 端块 %}

但我很困惑,我不知道我在寻找什么或如何识别我缺少的东西。我将不胜感激任何建议或意见。

如果我不清楚,对不起,因为我似乎没有真正理解这个问题,而且绝对不是 Vue 也不是 Shopware 精通,但想学习。谢谢

4

1 回答 1

0

也许您正在 Shopware 中寻找“自定义字段”,此功能允许您将自定义字段附加到实体。

文档:https ://developer.shopware.com/docs/guides/plugins/plugins/framework/custom-field/add-custom-field

查看:“向实体添加自定义字段”

如果您检查 ProductEntity 类,您可以看到正在使用的特征:使用 EntityCustomFieldsTrait;

如果您添加文档中解释的配置,您正在添加的自定义字段将在管理中进行编辑。

于 2022-01-23T13:20:48.257 回答