There is third party custom module. For add entries they used service contract entities. I need to add one more entry. Don't want to touch third party module. How can i extend their interface and module and after save data in table. I've created field in table. But unable to override interface and Model and save entry. I know there is concept Extension Attributes for this but not getting how to archive.

Please help me on this.

1 Answer 1


Here you have to use the Extension attribute concept but ensure that the 3-rd party Data interface Vendor\Module\Api\Data\{PovideName}Interface has two functions public function getExtensionAttributes and setExtensionAttributes.

Then you can use the extension attribute.

If you using a different database table then you have to implement service contact for this custom table, then expose your data interface to as 3rd party extension extension attribute. An example:

<extension_attributes for="Magento\Catalog\Api\Data\ProductInterface">
    <attribute code="stock_item" type="Magento\CatalogInventory\Api\Data\StockItemInterface" />

Here you can see Magento\CatalogInventory\Api\Data\StockItemInterface as extension attribute field for Magento\Catalog\Api\Data\ProductInterface"

See https://devdocs.magento.com/guides/v2.4/extension-dev-guide/extension_attributes/adding-attributes.html#extension-attributes-configuration

And you can better understand from fooman article: https://store.fooman.co.nz/blog/an-introduction-to-extension-attributes.html

  • using afterSave plugin for save data. But same problem I am using third party module resource for save. My data is not saving into Database (same table I've created a new field). Can you please explain more.
    – Nadim
    Nov 27, 2020 at 12:03

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.