Skip to content

Commit ac1b242

Browse files
committed
AC-7039:: Customer Import: update to disable_auto_group_change ignored 
1 parent 9f8cd4c commit ac1b242

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ protected function _prepareDataForUpdate(array $rowData)
407407
$entitiesToUpdate = [];
408408
$attributesToSave = [];
409409

410+
// entity table data
410411
$now = new \DateTime();
411412
if (empty($rowData['created_at'])) {
412413
$createdAt = $now;
@@ -423,10 +424,13 @@ protected function _prepareDataForUpdate(array $rowData)
423424
$entityId = $this->_getNextEntityId();
424425
$this->_newCustomers[$emailInLowercase][$rowData[self::COLUMN_WEBSITE]] = $entityId;
425426
}
427+
428+
// password change/set
426429
if (isset($rowData['password']) && strlen($rowData['password'])) {
427430
$rowData['password_hash'] = $this->_customerModel->hashPassword($rowData['password']);
428431
}
429432
$entityRow = ['entity_id' => $entityId];
433+
// attribute values
430434
foreach (array_intersect_key($rowData, $this->_attributes) as $attributeCode => $value) {
431435
$attributeParameters = $this->_attributes[$attributeCode];
432436
if (in_array($attributeParameters['type'], ['select', 'boolean'])) {
@@ -478,15 +482,16 @@ protected function _prepareDataForUpdate(array $rowData)
478482
$entityRow['is_active'] = 1;
479483
$entitiesToCreate[] = $entityRow;
480484
} else {
481-
$COLUMN_DISABLE_AUTO_GROUP_CHANGE=CustomerInterface::DISABLE_AUTO_GROUP_CHANGE;
485+
// edit
486+
$columnDisableAutoGroupChange=CustomerInterface::DISABLE_AUTO_GROUP_CHANGE;
482487
$entityRow['updated_at'] = $now->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
483488
if (!empty($rowData[self::COLUMN_STORE])) {
484489
$entityRow['store_id'] = $this->_storeCodeToId[$rowData[self::COLUMN_STORE]];
485490
} else {
486491
$entityRow['store_id'] = $this->getCustomerStoreId($emailInLowercase, $rowData[self::COLUMN_WEBSITE]);
487492
}
488-
if (!empty($rowData[$COLUMN_DISABLE_AUTO_GROUP_CHANGE])) {
489-
$entityRow[$COLUMN_DISABLE_AUTO_GROUP_CHANGE] = $rowData[$COLUMN_DISABLE_AUTO_GROUP_CHANGE];
493+
if (!empty($rowData[$columnDisableAutoGroupChange])) {
494+
$entityRow[$columnDisableAutoGroupChange] = $rowData[$columnDisableAutoGroupChange];
490495
}
491496
$entitiesToUpdate[] = $entityRow;
492497
}

dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ public function testImportData()
157157
$updatedCustomer->getCreatedAt(),
158158
'Creation date must be changed'
159159
);
160+
$this->assertNotEquals(
161+
$existingCustomer->getDisableAutoGroupChange(),
162+
$updatedCustomer->getDisableAutoGroupChange(),
163+
'disable_auto_group_change must be changed'
164+
);
160165
$this->assertEquals(
161166
$existingCustomer->getGender(),
162167
$updatedCustomer->getGender(),
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
email,_website,_store,confirmation,created_at,created_in,default_billing,default_shipping,disable_auto_group_change,dob,firstname,gender,group_id,lastname,middlename,password_hash,prefix,rp_token,rp_token_created_at,store_id,suffix,taxvat,website_id,password
22
AnthonyANealy@magento.com,base,admin,,5/6/2012 15:53,Admin,1,1,0,5/6/2010,Anthony,Female,1,Nealy,A.,6a9c9bfb2ba88a6ad2a64e7402df44a763e0c48cd21d7af9e7e796cd4677ee28:RF,,,,0,,,1,
33
LoriBBanks@magento.com,admin,admin,,5/6/2012 15:59,Admin,3,3,0,5/6/2010,Lori,Female,1,Banks,B.,7ad6dbdc83d3e9f598825dc58b84678c7351e4281f6bc2b277a32dcd88b9756b:pz,,,,0,,,0,
4-
CharlesTAlston@teleworm.us,base,admin,,5/6/2012 16:13,Admin,4,4,0,,Jhon,Female,1,Doe,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
4+
CharlesTAlston@teleworm.us,base,admin,,5/6/2012 16:13,Admin,4,4,1,,Jhon,Female,1,Doe,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
55
customer@example.com,base,admin,,5/6/2012 16:15,Admin,4,4,0,,Firstname,Female,1,Lastname,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
66
julie.worrell@example.com,base,admin,,5/6/2012 16:19,Admin,4,4,0,,Julie,Female,1,Worrell,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
77
david.lamar@example.com,base,admin,,5/6/2012 16:25,Admin,4,4,0,,David,,1,Lamar,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,

0 commit comments

Comments
 (0)