我已经在管理中创建了一个插件,我想将带有车辆的manyToMany产品插入到Shopware 6数据库中。从下面的代码中,我尝试将'92961afbc50e4380b3af86b257630ade'插入到'vehicles_product'表的'product_id'列中:
import template from './sw-vehicles-import.html.twig';
const { Component, Mixin } = Shopware;
Component.register('sw-vehicles-import', {
template,
inject: ['importExport', 'repositoryFactory', 'feature'],
mixins: [
Mixin.getByName('notification'),
],
metaInfo() {
return {
title: this.$createTitle()
};
},
data() {
return {
importFile: null,
repository: null,
entity: undefined,
};
},
computed: {
},
created() {
this.repository = this.repositoryFactory.create('vehicles');
},
methods: {
onStartProcess() {
this.entity = this.repository.create(Shopware.Context.api);
this.entity.categoryFilter = 'CategoryName';
this.entity.featureFilter = 'FeatureName';
this.entity.products.productId = '92961afbc50e4380b3af86b257630ade';
this.repository.save(this.entity, Shopware.Context.api);
}
}
});
构建过程不起作用,我做错了什么?你能帮帮我吗?
1条答案
按热度按时间cwdobuhd1#
如果关联尚不存在,则需要为该关联创建一个新的实体集合。