So practically, i'm importing data over API and saving it like this :
(not all the code but only the relevant)
$addressarray
->setCustomAttribute('exact_address_id', $contactaddress['ID'])
->setCustomerId($customerrep->getId())
->setFirstname($contact['firstname'])
->setLastname($contact['lastname'])
->setCountryId($contactaddress['Country'])
->setRegionId(0)
->setPostcode($contactaddress['Postcode'])
->setCity($contactaddress['City'])
->setTelephone($contact['account']['Phone'])
->setFax($contact['account']['Fax'])
->setCompany($contactaddress['AccountName'])
->setStreet(array($contactaddressstreet))
->setVatId($contact['account']['VATNumber']);
if ($contact['account']['AddressLine1'] == $contactaddress['AddressLine1']) {
$addressarray->setIsDefaultBilling(true);
$addressarray->setIsDefaultShipping(true);
} else {
$addressarray->setIsDefaultBilling(false);
$addressarray->setIsDefaultShipping(false);
}
try {
$address->save($addressarray);
And everything seems to work fine , everything is filled in and in the database addresses are created.
BUT
Even though my database table customer_address_entity
says 'BE
' (which is id for Belgium) under country_id
the field itself is empty.
Even more so when i save the customer myself with the address nothing really changes. Its still BE
.
Anyone any idea?
Github : Github magento 2 report