Skip to content

Commit 288cf22

Browse files
AnujnehraAnujnehra
authored andcommitted
ACP2E-2301: Customers and Addresses (single file) Import fails
1 parent 5636e6c commit 288cf22

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

app/code/Magento/CustomerImportExport/Model/Import/CustomerComposite.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,17 @@ protected function _importData()
280280
{
281281
if ($this->getIds()) {
282282
$this->_customerEntity->setIds($this->getIds());
283-
$this->_addressEntity->setCustomerAttributes($this->_customerAttributes)->setIds($this->getIds());
284283
}
285284
$result = $this->_customerEntity->importData();
286285
$this->countItemsCreated += $this->_customerEntity->getCreatedItemsCount();
287286
$this->countItemsUpdated += $this->_customerEntity->getUpdatedItemsCount();
288287
$this->countItemsDeleted += $this->_customerEntity->getDeletedItemsCount();
289288
if ($this->getBehavior() != \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE) {
290-
$result = $result && $this->_addressEntity->setCustomerAttributes($this->_customerAttributes)->importData();
289+
$addressEntityObject = $this->_addressEntity->setCustomerAttributes($this->_customerAttributes);
290+
if ($this->getIds() && $addressEntityObject !== null) {
291+
$addressEntityObject->setIds($this->getIds());
292+
}
293+
$result = $result && $addressEntityObject->importData();
291294
}
292295
if ($result) {
293296
$this->indexerProcessor->markIndexerAsInvalid();

app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/CustomerCompositeTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,17 @@ protected function _getModelMockForImportData($isDeleteBehavior, $customerImport
262262
if ($isDeleteBehavior || !$customerImport) {
263263
$addressEntity->expects($this->never())->method('importData');
264264
} else {
265-
$addressEntity->expects($this->once())->method('setCustomerAttributes')->willReturnSelf();
265+
$addressEntity->expects($this->atMost(2))->method('setCustomerAttributes')->willReturnSelf();
266266
$addressEntity->expects($this->once())->method('importData')->willReturn($addressImport);
267267
}
268268

269269
$data = $this->_getModelDependencies();
270270
$data['customer_entity'] = $customerEntity;
271271
$data['address_entity'] = $addressEntity;
272272

273-
return $this->_createModelMock($data);
273+
$obj = $this->_createModelMock($data);
274+
$obj->setIds([1, 2]);
275+
return $obj;
274276
}
275277

276278
/**

0 commit comments

Comments
 (0)