Question

I have added a custom extension attribute following this guide.

However, I am struggling to understand it's purpose. By what I can see they are setting their extension attribute on the order every time the order is requested. However, they are also saving the data to a custom table using their own custom model.

So what is the point in adding an extension attribute? If you can just get that data using the model/repository?

Was it helpful?

Solution

From https://devdocs.magento.com/guides/v2.3/extension-dev-guide/extension_attributes/adding-attributes.html

Third-party developers cannot change the API Data interfaces defined in the Magento Core code. However, most of these entities have a feature called extension attributes. Check the interface for the methods getExtensionAttributes() and setExtensionAttributes() to determine if they are available for the entity.

In other words... you as a developer cannot change the API Interfaces (and you shouldn't) but using extension attributes you can add your own meta data to the entities you need without changing how the API looks and works.
In other other words.... the extension attributes, provide a separation between what's core data and what's custom data.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top