I have one custom module and I need to get properties name list in this module as a multi-select.
How it’s possible in shopware 6?
Here is my code, please check.
custom-product-detail.html.twig
<sw-entity-multi-select
:localMode="module.isNew()"
:label="$t('custom-product.detail.assignPropertyLabel')"
v-model="module.options">
</sw-entity-multi-select>
custom-product-detail/index.js
import template from './custom-product-detail.html.twig';
const { Component, Mixin } = Shopware;
const { Criteria } = Shopware.Data;
const newLocal = 'custom_product';
Component.register('custom-product-detail', {
template,
inject: [
'repositoryFactory',
],
mixins: [
Mixin.getByName('notification')
],
metaInfo() {
return {
title: this.$createTitle()
};
},
data() {
return {
module: null,
isLoading: false,
processSuccess: false,
repository: null,
repositoryProperties: null,
properties: []
};
},
created() {
this.repository = this.repositoryFactory.create(newLocal);
this.repositoryProperties = this.repositoryFactory.create(property_group);
this.getModule();
this.loadEntityData();
},
methods: {
getModule() {
this.repository.get(this.repositoryProperties, this.$route.params.id, Shopware.Context.api).then((entity) => {
this.module = entity;
this.isLoading = false;
});
},
loadEntityData() {
this.isLoading = true;
var criteria = new Criteria();
criteria.addAssociation('options');
return this.repositoryProperties.search(criteria, Shopware.Context.api).then((result) => {
this.total = result.total;
this.properties = result;
this.isLoading = false;
return result;
}).catch(() => {
this.isLoading = false;
});
},
onClickSave() {
this.isLoading = true;
this.repository
.save(this.module, Shopware.Context.api)
.then(() => {
this.getModule();
this.isLoading = false;
this.processSuccess = true;
}).catch((exception) => {
this.isLoading = false;
this.createNotificationError({
title: this.$t('custom-product.detail.error-message'),
message: exception
});
});
},
saveFinish() {
this.processSuccess = false;
}
}
});
I have tried but I got the below error.