0

What is the process for saving an extension attribute to the database, when passed over using the REST API? How does it know which table / field to save the value to? the method are being generated in the OrderExtension.php but don't seem to do anything.

I can't seem to find an example of this that doesn't use the object manager (How to insert data in custom table using REST API in Magento2). I have also looked through the Magento/Giftmessage code, but it seems to just magically know where to save this.

I have tried adding these sort of lines to the extension_attributes.xml -

 <join reference_table="" reference_field="" join_on_field="">
            <field></field>
 </join>

But it doesn't seem to do anything when the correct fields are added.

1 Answer 1

2

The answer is that extension attributes do not know where and how behave, only developer can implement logic which will process them, in your case - save to database. It is not an out of the box functionality. Extension attributes helps you only with extending of interfaces, nothing more.

Let us say that you pass some data through rest api. You must, at some point of process, capture those data and handle them eg. by making a plugin for appropriate method. I can't help more because the "how to do that" depends on many factors and i do not know full background plus serving such a solution might be very time consuming. I hope that I pointed you to the right direction at least.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.