I am trying to add extension attributes to customer entity.
I set extension_attributes.xml
as follows:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
<extension_attributes for="Magento\Customer\Api\Data\CustomerInterface">
<attribute code="my_attribute" type="Text">
<join reference_table="my_entity"
reference_field="customer_id"
join_on_field="entity_id">
<field>my_entity_attribute</field>
</join>
</attribute>
</extension_attributes>
</config>
The table my_entity
exists and it has a column called customer_id
and I want to join this field to the entity_id
field in the customer_entity
table, and add my_entity_attribute
value as the ultimate extension attribute to customer.
What am I doing wrong?
To test this, I am doing a GET rest api call to endpoint customers/me
and debugging $this->_getExtensionAttributes()
inside \Magento\Customer\Model\Data\Customer::getExtensionAttributes()
, but it gives null.