Skip to content

Commit 7fa114a

Browse files
committed
Merge remote-tracking branch 'magento-ce/develop' into SPRINT-27-PR
2 parents e417fb5 + b3b6ed4 commit 7fa114a

File tree

7 files changed

+289
-157
lines changed

7 files changed

+289
-157
lines changed

app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,13 @@ public function __construct(
145145
public function save(\Magento\Customer\Api\Data\CustomerInterface $customer, $passwordHash = null)
146146
{
147147
$prevCustomerData = null;
148+
$prevCustomerDataArr = null;
148149
if ($customer->getId()) {
149150
$prevCustomerData = $this->getById($customer->getId());
151+
$prevCustomerDataArr = $prevCustomerData->__toArray();
150152
}
153+
/** @var $customer \Magento\Customer\Model\Data\Customer */
154+
$customerArr = $customer->__toArray();
151155
$customer = $this->imageProcessor->save(
152156
$customer,
153157
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
@@ -185,6 +189,20 @@ public function save(\Magento\Customer\Api\Data\CustomerInterface $customer, $pa
185189
$customerModel->setRpToken(null);
186190
$customerModel->setRpTokenCreatedAt(null);
187191
}
192+
if (!array_key_exists('default_billing', $customerArr) &&
193+
null !== $prevCustomerDataArr &&
194+
array_key_exists('default_billing', $prevCustomerDataArr)
195+
) {
196+
$customerModel->setDefaultBilling($prevCustomerDataArr['default_billing']);
197+
}
198+
199+
if (!array_key_exists('default_shipping', $customerArr) &&
200+
null !== $prevCustomerDataArr &&
201+
array_key_exists('default_shipping', $prevCustomerDataArr)
202+
) {
203+
$customerModel->setDefaultShipping($prevCustomerDataArr['default_shipping']);
204+
}
205+
188206
$customerModel->save();
189207
$this->customerRegistry->push($customerModel);
190208
$customerId = $customerModel->getId();

app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,29 +101,22 @@ protected function setUp()
101101
$this->getMock(\Magento\Customer\Model\ResourceModel\Customer::class, [], [], '', false);
102102
$this->customerRegistry = $this->getMock(\Magento\Customer\Model\CustomerRegistry::class, [], [], '', false);
103103
$this->dataObjectHelper = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false);
104-
$this->customerFactory = $this->getMock(
105-
\Magento\Customer\Model\CustomerFactory::class,
106-
['create'],
107-
[],
108-
'',
109-
false
110-
);
104+
$this->customerFactory =
105+
$this->getMock(\Magento\Customer\Model\CustomerFactory::class, ['create'], [], '', false);
111106
$this->customerSecureFactory = $this->getMock(
112107
\Magento\Customer\Model\Data\CustomerSecureFactory::class,
113108
['create'],
114109
[],
115110
'',
116111
false
117112
);
118-
119113
$this->addressRepository = $this->getMock(
120114
\Magento\Customer\Model\ResourceModel\AddressRepository::class,
121115
[],
122116
[],
123117
'',
124118
false
125119
);
126-
127120
$this->customerMetadata = $this->getMockForAbstractClass(
128121
\Magento\Customer\Api\CustomerMetadataInterface::class,
129122
[],
@@ -172,11 +165,15 @@ protected function setUp()
172165
\Magento\Customer\Api\Data\CustomerInterface::class,
173166
[],
174167
'',
175-
false
168+
true,
169+
true,
170+
true,
171+
[
172+
'__toArray'
173+
]
176174
);
177175
$this->collectionProcessorMock = $this->getMockBuilder(CollectionProcessorInterface::class)
178176
->getMock();
179-
180177
$this->model = new \Magento\Customer\Model\ResourceModel\CustomerRepository(
181178
$this->customerFactory,
182179
$this->customerSecureFactory,
@@ -254,6 +251,11 @@ public function testSave()
254251
'',
255252
false
256253
);
254+
255+
$this->customer->expects($this->atLeastOnce())
256+
->method('__toArray')
257+
->willReturn(['default_billing', 'default_shipping']);
258+
257259
$customerAttributesMetaData = $this->getMockForAbstractClass(
258260
\Magento\Framework\Api\CustomAttributesDataInterface::class,
259261
[],
@@ -495,6 +497,11 @@ public function testSaveWithPasswordHash()
495497
'getId'
496498
]
497499
);
500+
501+
$this->customer->expects($this->atLeastOnce())
502+
->method('__toArray')
503+
->willReturn(['default_billing', 'default_shipping']);
504+
498505
$customerModel = $this->getMock(
499506
\Magento\Customer\Model\Customer::class,
500507
[

app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ public function setShippingItemsInformation($info)
395395
}
396396
}
397397

398+
$this->prepareShippingAssignment($quote);
399+
398400
/**
399401
* Delete all not virtual quote items which are not added to shipping address
400402
* MultishippingQty should be defined for each quote item when it processed with _addShippingItem

0 commit comments

Comments
 (0)