我编写了一个扩展将数据添加到Shopware 6中的ProductEntity中,并使用了以下教程:https://developer.shopware.com/docs/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities
我还使用了另一个教程(https://developer.shopware.com/docs/guides/plugins/plugins/administration/add-new-tab)将一个新选项卡添加到产品详细信息视图中。到目前为止一切正常。
在“产品详细信息”视图中,我在自定义选项卡中添加了一个文本字段。但我的问题是:如何将我的数据放到视图中?当加载详细信息视图时,我想将我的新关联添加到产品中。因此,我试图从Shopware重写组件,如下所示:
Shopware.Component.override('sw-product-detail', {
template,
mounted() {
const criteria = this.productCriteria;
criteria.addAssociation('myNewAssociation');
this.productCriteria =criteria;
},
});这不起作用,因为productCriteria没有setter (可以在这里找到原始组件:https://github.com/shopware/platform/blob/6.4.1.0/src/Administration/Resources/app/administration/src/module/sw-product/page/sw-product-detail/index.js)
有人知道我如何在Shopware 6中的vue.js中添加一个自定义关联吗?向产品详细信息视图注入自定义关联的正确方法是什么,这样我就可以在新的自定义选项卡中使用数据了?文档总是在有趣的时候停止.
发布于 2021-06-12 15:48:16
我建议重写productCriteria方法,并调用父方法,使其不需要完全复制现有代码,如下所示:
Shopware.Component.override('sw-product-detail', {
template,
computed: {
productCriteria() {
const criteria = this.$super('productCriteria');
criteria.addAssociation('myNewAssociation');
return criteria;
},
},
});如果有用的话请告诉我。
我相信您也不需要在覆盖中提到template (当我上次这样做时,模板被显示了两次)
编辑:所有好的模板。
https://stackoverflow.com/questions/67947942
复制相似问题