// Copy customer number into billing address from customer
$result[0
]['customer'
]['defaultBillingAddress'
]['number'
] =
$customer->
getNumber();
// Casting null values to empty strings to fulfill the restrictions of the s_order_billingaddress table
$billingAddress =
array_map(function D
$value) { return (string) $value;
},
$result[0
]['customer'
]['defaultBillingAddress'
]);
$billingCountry =
$this->
get('models'
)->
find(Country::
class,
$result[0
]['customer'
]['defaultBillingAddress'
]['countryId'
]);
// Create new entry in s_order_billingaddress
$billingModel =
new Shopware\Models\Order\
Billing();
$billingModel->
fromArray($billingAddress);
$billingModel->
setCountry($billingCountry);
$billingModel->
setCustomer($customer);
$billingModel->
setOrder($orderModel);
$this->
get('models'
)->
persist($billingModel);
// Casting null values to empty strings to fulfill the restrictions of the s_order_shippingaddress table
$shippingAddress =
array_map(function D
$value) { return (string) $value;
},
$result[0
]['customer'
]['defaultShippingAddress'
]);