Created
July 3, 2021 21:45
-
-
Save breaker92/e16041c3820af3995a47806b920773aa to your computer and use it in GitHub Desktop.
Add custom Fields to property options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Component.override('sw-property-option-detail', { | |
template, | |
data() { | |
return { | |
... | |
customFieldSets: [] | |
}; | |
}, | |
computed: { | |
customFieldSetRepository() { | |
return this.repositoryFactory.create('custom_field_set'); | |
}, | |
customFieldSetCriteria() { | |
const criteria = new Criteria(1, 100); | |
criteria.addFilter(Criteria.equals('relations.entityName', 'propertyOption')); | |
criteria | |
.getAssociation('customFields') | |
.addSorting(Criteria.sort('config.customFieldPosition', 'ASC', true)); | |
return criteria; | |
}, | |
}, | |
methods: { | |
loadEntityData() { | |
... | |
this.customFieldSetRepository | |
.search(this.customFieldSetCriteria, Shopware.Context.api) | |
.then((result) => { | |
this.customFieldSets = result.filter((set) => set.customFields.length > 0); | |
}); | |
}, | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<sw-card :title="$tc('sw-settings-custom-field.general.mainMenuItemGeneral')" | |
v-if="customFieldSets.length > 0" | |
:isLoading="isLoading"> | |
<sw-custom-field-set-renderer | |
v-if="currentOption" | |
:entity="currentOption" | |
:sets="customFieldSets" | |
:disabled="!allowEdit"> | |
</sw-custom-field-set-renderer> | |
</sw-card> | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment