I have created a custom attribute of type customer_address and I would like to have the API to return me the value as an attribute when I call the API to receive an order.
Attribute:
private function upgradeExternalKeyAddressCustomer($customerSetup)
{
$attributesInfo = [
'mod_external_key' => [
'label' => __('External Key'),
'type' => 'varchar',
'input' => 'text',
'position' => 200,
'visible' => 1,
'required' => 0,
'system' => 0,
],
];
foreach ($attributesInfo as $attributeCode => $attributeParams) {
$customerSetup->addAttribute('customer_address', $attributeCode, $attributeParams);
}
foreach ($attributesInfo as $attributeCode => $attributeParams) {
$attribute = $customerSetup->getEavConfig()->getAttribute('customer_address', $attributeCode);
$attribute->setData(
'used_in_forms',
['adminhtml_customer_address', 'customer_address_edit', 'customer_register_address']
);
$attribute->save();
}
}
How to do this?
1 Answer 1
try this blog it will return your custom attribute in order api response https://www.atwix.com/development/adding-custom-attribute-to-api-response-in-magento-2/
answered Nov 12, 2018 at 12:08
Rakesh Varma
2,25412 silver badges19 bronze badges
-
1This tutorial is about extension attributes. How can I do that for an attribute outside of extension attributes ?Gustavo Ulyssea– Gustavo Ulyssea2020年07月06日 15:07:55 +00:00Commented Jul 6, 2020 at 15:07
default