customer_entity attribute data not updated

When a user changes the email address, first name or last name in the account, which is saved in the customer_entity table that data is not being updated to Magento 2. 
Current code

if (is_null($m2Id)) {
// code
} else {
//update
$customer2 = Mage2CustomerEntity::model()->find("entity_id = {$m2Id}");
$customer2->group_id = $groupId2;
$customer2->updated_at = $customer->updated_at;
$customer2->is_active = $customer->is_active;
}

Correct code

if (is_null($m2Id)) {
// code
} else {
//update
$customer2 = Mage2CustomerEntity::model()->find("entity_id = {$m2Id}");
foreach ($customer2->attributes as $key => $value) {
if (isset($customer->$key)) {
$customer2->$key = $customer->$key;
}
}
$customer2->entity_id = ($keepOriginalId) ? $customer->entity_id : null;
//because website_id, store_id, group_id was changed
$customer2->website_id = $websiteId2;
$customer2->store_id = $storeId2;
$customer2->group_id = $groupId2;
}

1 answer

Profile photo of Mall Staff 184060.00 $tone January 21, 2021
Public

Hi Danny,

When a user changes the email address, first name or last name in the account, which is saved in the customer_entity table that data is not being updated to Magento 2. 

Please note that in Magento 1, after a customer changed the email, first name, last name:
+ email is stored in the `customer_entity` table only. 
+ First name, last name will be stored in the related EAV data table: customer_entity_varchar
Thus, you shouldn’t append the tweak code as you suggested (the bold text code lines are not needed in the delta phase)

else {
//update
$customer2 = Mage2CustomerEntity::model()->find("entity_id = {$m2Id}");
foreach ($customer2->attributes as $key => $value) {
if (isset($customer->$key)) {
$customer2->$key = $customer->$key;
}
}
$customer2->entity_id = ($keepOriginalId) ? $customer->entity_id : null;
//because website_id, store_id, group_id was changed
$customer2->website_id = $websiteId2;
$customer2->store_id = $storeId2;
$customer2->group_id = $groupId2;
}

I saw that you used an old version of our migration tool. We did handle the delta update functionality for the `email` in the latest Pro version 3.2.5: http://prntscr.com/xbx3j8

And we did handle delta updates for both customer’s first name and last name in the earlier versions.

After finishing the delta migration in step #6, you have to reindex the data to see the new changes in the customers grid view in your M2 backend.
 
I hope that helps. 
 
Regards,
Mall.
 

#1

Please login or Register to Submit Answer

Written By

Comments