Skip to content

Commit

Permalink
Merge pull request #14 from sw-4863-fix-changing-countries-in-orders …
Browse files Browse the repository at this point in the history
…to master

* commit 'a6d6e94622e199b653808fea3d6905bfa4dd8105':
  SW-4863 - Load countryModel before storing billingAddress
  • Loading branch information
dnoegel committed Jan 28, 2013
2 parents 9763472 + a6d6e94 commit 79bb009
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions engine/Shopware/Controllers/Backend/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -1357,8 +1357,8 @@ private function getAssociatedData($data, $order, $billing, $shipping)
//created documents models would be overwritten.
unset($data['documents']);

$data['billing'] = $data['billing'][0];
$data['shipping'] = $data['shipping'][0];
$data['billing'] = $this->prepareAddressData($data['billing'][0]);
$data['shipping'] = $this->prepareAddressData($data['shipping'][0]);
$data['attribute'] = $data['attribute'][0];
$data['billing']['attribute'] = $data['billingAttribute'][0];
$data['shipping']['attribute'] = $data['shippingAttribute'][0];
Expand All @@ -1367,7 +1367,24 @@ private function getAssociatedData($data, $order, $billing, $shipping)
return $data;
}

/**
* Prepare address data - loads countryModel from a given countryId
*
* @param $data Array
* @return Array
*/
protected function prepareAddressData(array $data)
{
if (isset($data['countryId']) && !empty($data['countryId'])) {
$countryModel = $this->getCountryRepository()->find($data['countryId']);
if ($countryModel) {
$data['country'] = $countryModel;
}
unset($data['countryId']);
}

return $data;
}

/**
* Creates the status mail order for the passed order id and new status object.
Expand Down

0 comments on commit 79bb009

Please sign in to comment.