Skip to content

Commit 586ac08

Browse files
author
Oleksandr Gorkun
committed
MAGETWO-83426: [Performance] Customer Import check data does not complete
1 parent 72ef5ae commit 586ac08

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -484,12 +484,15 @@ public function prepareCustomerData(\Traversable $rows)
484484
parent::prepareCustomerData($rows);
485485
$ids = [];
486486
foreach ($rows as $customerData) {
487-
$email = isset($customerData[static::COLUMN_EMAIL])
488-
? $customerData[static::COLUMN_EMAIL] : null;
489-
$websiteId = isset($customerData[static::COLUMN_WEBSITE])
490-
? $this->getWebsiteId($customerData[static::COLUMN_WEBSITE])
491-
: false;
492-
if ($email && $websiteId !== false) {
487+
if (isset($customerData[static::COLUMN_EMAIL])
488+
&& $email = $customerData[static::COLUMN_EMAIL]
489+
&& isset($customerData[static::COLUMN_WEBSITE])
490+
&& (
491+
$websiteId = $this->getWebsiteId(
492+
$customerData[static::COLUMN_WEBSITE]
493+
)
494+
) !== false
495+
) {
493496
$id = $this->getCustomerStorage()
494497
->getCustomerId($email, $websiteId);
495498
if ($id) {

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ protected function _getModelMockForTestImportDataWithCustomBehaviour()
355355
'attributes' => [],
356356
'defaults' => [],
357357
];
358-
359358
// entity adapter mock
360359
$modelMock = $this->getMock(
361360
'Magento\CustomerImportExport\Model\Import\Address',
@@ -377,11 +376,10 @@ protected function _getModelMockForTestImportDataWithCustomBehaviour()
377376
true,
378377
true
379378
);
380-
379+
//Adding behaviours
381380
$availableBehaviors = new \ReflectionProperty($modelMock, '_availableBehaviors');
382381
$availableBehaviors->setAccessible(true);
383382
$availableBehaviors->setValue($modelMock, $this->_availableBehaviors);
384-
385383
// mock to imitate data source model
386384
$dataSourceMock = $this->getMock(
387385
'Magento\ImportExport\Model\ResourceModel\Import\Data',
@@ -402,39 +400,33 @@ protected function _getModelMockForTestImportDataWithCustomBehaviour()
402400
);
403401
$dataSourceModel->setAccessible(true);
404402
$dataSourceModel->setValue($modelMock, $dataSourceMock);
405-
406403
// mock expects for entity adapter
407404
$modelMock->expects($this->any())->method('validateRow')->will($this->returnValue(true));
408405
$modelMock->expects($this->any())
409406
->method('getErrorAggregator')
410407
->will($this->returnValue($this->errorAggregator));
411-
412408
$modelMock->expects($this->any())->method('_prepareDataForUpdate')->will($this->returnValue($updateResult));
413-
414409
$modelMock->expects(
415410
$this->any()
416411
)->method(
417412
'_saveAddressEntities'
418413
)->will(
419414
$this->returnCallback([$this, 'validateSaveAddressEntities'])
420415
);
421-
422416
$modelMock->expects($this->any())->method('_saveAddressAttributes')->will($this->returnValue($modelMock));
423-
424417
$modelMock->expects($this->any())->method('_saveCustomerDefaults')->will($this->returnValue($modelMock));
425-
426418
$modelMock->expects(
427419
$this->any()
428420
)->method(
429421
'_deleteAddressEntities'
430422
)->will(
431423
$this->returnCallback([$this, 'validateDeleteAddressEntities'])
432424
);
433-
434425
$modelMock->expects($this->any())->method('_mergeEntityAttributes')->will($this->returnValue([]));
435426
$modelMock->expects($this->any())
436427
->method('getCustomerStorage')
437428
->willReturn($this->_createCustomerStorageMock());
429+
438430
return $modelMock;
439431
}
440432

0 commit comments

Comments
 (0)