I followed this guide to add a custom product attribute to quote and sales order item throughout the order process and this works fine.
My custom attribute is added to the
sales_order_item table correctly but will not return in the order api call:
/rest/V1/orders/X . The item in the order are present but the custom added attribute seems to be missing.
How do I add this
sales_order_item attribute to the API output?
I tried it by adding a "extension_attributes.xml" to my custom module (that included the custom attribute: see earlier mentioned link) but that seems to have no effect:
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd"> <extension_attributes for="Magento\Sales\Api\Data\OrderItemInterface"> <attribute code="deliverycode" type="string" /> </extension_attributes> </config>
Thanks for the help!
Still haven't resolved the issues after trying some minor things. I ran into this topic, which is closely related to my issue. I am trying to adjust the code to suit my needs but I haven't found the answer yet after a few hours of trying to switch the code the be suitable for "sales_order_item". If anyone has any solutions or tips to push me in the right direction they are very much appreciated!