An Adobe Commerce developer needs to add custom data to orders retrieved through the API.
While following best practices, how should the developer accomplish this?
Extension attributes are the supported mechanism for adding data to Adobe Commerce API data interfaces. An after plugin on Magento\Sales\Api\OrderRepositoryInterface can populate the extension attribute on the order returned by get() and on every order in the search results returned by getList(), ensuring the custom data is included in both API retrieval paths. Adobe’s extension-attribute guidance recommends repository after plugins for get and getList responses.
Magento\Sales\Api\OrderRepositoryInterface
get()
getList()
get
getList
Community Discussion