![](/img/trans.png)
[英]How to create a backend module with a custom listing in shopware 6?
[英]Shopware 6 create DB entry for custom entity
我正在尝试按照 BundleExample & Storefinder 为 Shopware6 构建一个插件,并且一直坚持为我的实体创建相应的条目。 我向管理员添加了一个模块,该模块具有 3 个组件:列表、详细信息和创建,分别路由到 [vendor-name].[plugin-name].list/.detail/.create。
从 custom\plugins[plugin-name]\src\Resources\administration\module[vendor-name]-[plugin-name]\index.js
routes:{
list:{
component: '[vendor-name]-[plugin-name]-list',
path: 'list'
},
detail:{
component: '[vendor-name]-[plugin-name]-detail',
path: 'detail/:id',
meta:{
parentPath: '[vendor-name].[plugin-name].list'
}
},
create:{
component: '[vendor-name]-[plugin-name]-create',
path: 'create',
meta:{
parentPath: '[vendor-name].[plugin-name].list'
}
}
/list 当数据库中没有条目时按预期显示,这意味着只有智能栏可见。 /detail 无法工作,因为还没有实体,所以没有 id。 /create 应该通过
created(){
this.repository = this.repositoryFactory.create('[vendor-name]_[plugin-name]');
this.repository.create(this.context);
}
但什么都没有发生。
我确定我在某处忽略了一个基本步骤,并且会感谢任何关于我如何让它实际生成条目的指针。 如果进一步的代码有助于澄清问题,我将很乐意提供。
this.repository.create(this.context);
行将在客户端创建您的自定义实体的实体 object。 要保存该实体,您必须调用this.repository.save(entity, this.context);
. 然后您应该能够在浏览器的开发控制台中看到正在发送到服务器的请求。
有关更多信息,请查看文档。
请记住this.repository.create(this.context);
创建一个空的虚拟实体,因此您至少需要设置自定义实体的所有必填字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.