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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
scroll top