Hi
I want to create and save a new field in product detail page in Shopware 6.
I don’t want to use the custom fields.
I want to create a new field in the products table and save the value from the admin product edit page.
How it is possible?
Hi
I want to create and save a new field in product detail page in Shopware 6.
I don’t want to use the custom fields.
I want to create a new field in the products table and save the value from the admin product edit page.
How it is possible?
maybe with entity extension -> Shopware 6: Entity extension
this only shows, how to extend the entity.
but the actual question is:
How can i store the value of my new field on click of Save button in the product edit page.
I’m also stuck with the same problem, in your case, were you able to fetch your input text in your backend?
I Try to do something similar for the OrderLineItems.
In the OrderLineItems it is not possible to configure custom fields so I made an entity extension.
But how can I now extend the Administration to save content the field of my extension ?
Maybe someone of the shopware team can provide an answer for that question ?
You can simply write your data into this.product.extensions.your-extension
Shopware will automatically write it to the database when you save the product (Autoloading might need to be active for this to work I’m not sure). This worked for me:
methods: {
// This is the @change Method on my Input
updateData(){
this.myExtension.option = this.selectedOption;
this.product.extensions.myExtension = this.myExtension;
}
},
created(){
if(!this.product.extensions.myExtension){
this.myExtension = this.myExtensionRepository.create(Shopware.Context.api);
this.myExtension.productId = this.product.id;
}else{
this.myExtension = this.product.extensions.myExtension;
this.selectedOption = this.product.extensions.myExtension.option;
}
}