When to use Extension Attributes instead of Custom Attributes?

It seems that both Custom Attributes and Extension Attributes can be used to add fields to entities. What should a developer consider when choosing between the two?

It seems that Custom Attribute fields may just “appear” on the backend, but will not just “appear” on the frontend in Magento Open Source. But they can be added to the frontend by editing the PHTML files I believe. Can Extension Attributes be presented on both the frontend and the backend? Will they just “appear” in either location? If not, how are they added to the PHTML fields? What must be done to get them to appear in the backend? How about Customers’ personal dashboards?

For instance, consider a text field on a Customer Address. This field should appear in the following Forms:

  1. Checkout Guest
  2. Checkout Logged In (Store New Address)
  3. Customer Dashboard -> Address Book -> Add New Address (customer_address_new)
  4. Customer Dashboard -> Address Book -> Edit Address (customer_address_edit)
  5. Admin Dashboard: Customers -> All Customers -> Edit -> Address tab (customer_index_edit)
  6. Admin Dashboard: Sales -> Orders -> Edit -> Billing Address

Should that be a Custom Attribute or Extension Attribute?

How about a field that would be directly on the Customer itself? Such a field should appear in the following Forms:

  1. Customer Account Create Form
  2. Customer Dashboard: Edit Account Information (customer_account_edit)
  3. Admin Dashboard: Customers -> All Customers -> Edit -> Account Information tab (customer_index_edit)

Should that be a Custom Attribute or Extension Attribute?

submitted by /u/dotancohen
[link] [comments]