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)) {
$email2 = addslashes($customer->email);
$condition = is_null($websiteId2) ? "email = '{$email2}' AND website_id IS NULL" : "email = '{$email2}' AND website_id = {$websiteId2}";
$customer2 = Mage2CustomerEntity::model()->find($condition);
if (!$customer2) {
//add new
$customer2 = new Mage2CustomerEntity();
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;
} else {
$canReset = UBMigrate::RESET_NO;
}
} 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)) {
$email2 = addslashes($customer->email);
$condition = is_null($websiteId2) ? "email = '{$email2}' AND website_id IS NULL" : "email = '{$email2}' AND website_id = {$websiteId2}";
$customer2 = Mage2CustomerEntity::model()->find($condition);
if (!$customer2) {
//add new
$customer2 = new Mage2CustomerEntity();
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;
} else {
$canReset = UBMigrate::RESET_NO;
}
} 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
Hi Danny,
Our team member Mall has just replied to you via this ticket, please check and follow up further there.
Regards,
Ubertheme team