I am trying to get the Custom Attribute I have in the sales_order_item to display on the rest/V1/orders/items API call. I was able to get the Attribute to display on the rest/V1/orders API call. Using a Magento\Sales\Api\OrderRepositoryInterface plugin. But the Attribute don't display on the rest/V1/orders/items API call. I was trying to use the OrderItemRepositoryInterface plugin, but I don't know what functions to add or if this is the correct way to do this.
Thanks.
Best Answer
You have to make
your Custom Attribute
attribute as extension attribute forMagento\Sales\Api\Data\OrderItemInterface
create
extension_attributes.xml
at your modulesapp/code/{Vendorname}/{ModuleName}/etc
.I assume that your field as varchar that why I have add type as string type variable (
type="string"
).Update,
As you want to expose that
rest/V1/orders/items
Api point then you have to create a plugin onMagento\Sales\Model\Order\ProductOption::add()
Here the plugin Class: