Skip to content

Commit 020d4c9

Browse files
committed
MAGETWO-91626: Countries from default website set when edit order address
- Fix issue with empty region_id
1 parent 36bae74 commit 020d4c9

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,6 @@ protected function _getAddress()
106106
*/
107107
protected function _prepareForm()
108108
{
109-
$address = $this->_getAddress();
110-
if ($address !== null) {
111-
$storeId = $this->_getAddress()
112-
->getOrder()
113-
->getStoreId();
114-
$this->_storeManager->setCurrentStore($storeId);
115-
}
116-
117109
parent::_prepareForm();
118110
$this->_form->setId('edit_form');
119111
$this->_form->setMethod('post');

app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ public function getAddressCollectionJson()
218218
*/
219219
protected function _prepareForm()
220220
{
221+
$storeId = $this->getCreateOrderModel()
222+
->getSession()
223+
->getStoreId();
224+
$this->_storeManager->setCurrentStore($storeId);
225+
221226
$fieldset = $this->_form->addFieldset('main', ['no_container' => true]);
222227

223228
$addressForm = $this->_customerFormFactory->create('customer_address', 'adminhtml_customer_address');

app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Address/FormTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\Framework\Registry;
1818
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1919
use Magento\Sales\Block\Adminhtml\Order\Address\Form;
20+
use Magento\Sales\Model\AdminOrder\Create;
2021
use Magento\Sales\Model\Order;
2122
use Magento\Sales\Model\Order\Address;
2223
use PHPUnit_Framework_MockObject_MockObject as MockObject;
@@ -57,6 +58,11 @@ class FormTest extends \PHPUnit\Framework\TestCase
5758
*/
5859
private $sessionQuote;
5960

61+
/**
62+
* @var Create|MockObject
63+
*/
64+
private $orderCreate;
65+
6066
protected function setUp()
6167
{
6268
$objectManager = new ObjectManager($this);
@@ -72,14 +78,21 @@ protected function setUp()
7278
->setMethods(['getStoreId', 'getStore'])
7379
->getMock();
7480

81+
$this->orderCreate = $this->getMockBuilder(Create::class)
82+
->disableOriginalConstructor()
83+
->getMock();
84+
$this->orderCreate->method('getSession')
85+
->willReturn($this->sessionQuote);
86+
7587
$this->addressBlock = $objectManager->getObject(
7688
Form::class,
7789
[
7890
'_formFactory' => $this->formFactory,
7991
'_customerFormFactory' => $this->customerFormFactory,
8092
'_coreRegistry' => $this->coreRegistry,
8193
'countriesCollection' => $this->countriesCollection,
82-
'sessionQuote' => $this->sessionQuote
94+
'sessionQuote' => $this->sessionQuote,
95+
'_orderCreate' => $this->orderCreate
8396
]
8497
);
8598
}

0 commit comments

Comments
 (0)