0

We have created an extension attribute which we would be accepting via customer address REST API

Endpoint: PUT customers/:customerId

Request body:

{
 "customer": {
 "email": "[email protected]",
 "firstname": "test",
 "lastname": "test",
 "addresses": [
 {
 "region": {
 "region_code": "NY",
 "region": "New York",
 "region_id": 43
 },
 "country_id": "US",
 "street": [
 "Address1",
 "Verified"
 ],
 "firstname": "test",
 "lastname": "test",
 "default_shipping": false,
 "default_billing": true,
 "telephone": "8600360471",
 "postcode": "98761",
 "city": "New York",
 "extension_attributes": {
 "verification_status": 1
 }
 }
 ]
 }
}

Created an observer on customer_address_save_before however the following returns null: $customerAddress->getExtensionAttributes();

public function execute(Observer $observer)
{
 $customerAddress = $observer->getCustomerAddress();
 $verificationStatus = $customerAddress->getExtensionAttributes();
}

I need to fetch the extension attribute to save it to the customer address via REST API

There is also a custom attribute created but that too is coming as null when passed via REST API

asked May 6, 2022 at 5:38

1 Answer 1

0

Have you correctly declared the extension attributes via extension_attributes.xml? You will have to declare verification_status along with the expected type for Magento\Customer\Api\Data\CustomerInterface if you haven't already.

More info can be found here:

answered May 6, 2022 at 13:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.