New column for product entity

Hello,

Based on bundle plugin for sw6 I want to create a different logic and not using custom fields.

Steps:

  1. Create a new column in product table

  2. use EntityExtensionInterface to a add a new Json Field

  3. Create a subscriber on product loaded and load data into product.extensions.newColumn

  4. Create in admin product edit a sw-entity-multi-select where I want for one product to assign more products in a json

  5. Load list of available product for selection, pre-populate assigned products, save select on each change

Most of the work is complete but I stopped when wanting to save the new column value via the admin api call.

For example:

POST

http://domani.com/api/v1/product/05e1008fc06343578492a76d2196a7c9/extensions/newColumn

Body:

{
    “yyy”: “xxxx”
}

Returns:

{

“errors”: [

{

“code”: “0”,

“status”: “500”,

“title”: “Internal Server Error”,

“detail”: “Attempted to call an undefined method named “getReferenceDefinition” of class “Shopware\Core\Framework\DataAbstractionLayer\Field\StringField”.”

}

]

}

This neither is possible:

http://domani.com/api/v1/product/05e1008fc06343578492a76d2196a7c9

PATCH

{

“newColumn”: {“xxx”:“yyy”}

}

 

Please advise if the above is possible .

 

We wanted to display the field separately from custom fields sets for an easier navigation/usage.

We can switch to many to many select with a new table for our parent / child products if not possible as we wanted into a simple json field.

 

Thank you,

AndreiB.

1 „Gefällt mir“