'additionalAddressLine1' =>
$data->
get('additionalAddressLine1'
),
'additionalAddressLine2' =>
$data->
get('additionalAddressLine2'
),
];
if ($data->
get('customFields'
) instanceof RequestDataBag
) { $addressData['customFields'
] =
$this->storeApiCustomFieldMapper->
map( CustomerAddressDefinition::ENTITY_NAME,
$data->
get('customFields'
) );
} $mappingEvent =
new DataMappingEvent($data,
$addressData,
$context->
getContext());
$this->eventDispatcher->
dispatch($mappingEvent, CustomerEvents::MAPPING_ADDRESS_CREATE
);
$addressData =
$mappingEvent->
getOutput();
$addressData['id'
] =
$addressId;
$addressData['customerId'
] =
$customer->
getId();
$this->addressRepository->
upsert([$addressData],
$context->
getContext());
$criteria =
new Criteria([$addressId]);
/** @var CustomerAddressEntity $address */