浏览文章
文章信息
Magento2 编程方式修改客户密码|用程序修改客户密码
14386
1、示例
$password = $customer[]$password_hash = $encryptor->($password)$customerModelData = $customerRepositoryInterface->($customer_id)$customerSecure = $customerRegistry->($customer_id)$customerSecure->()$customerSecure->()$customerSecure->($password_hash)$customerRepositoryInterface->($customerModelData$password_hash)代码:
$password = $customer['mobile']; // 设置客户初始密码为手机号码 $password_hash = $encryptor->getHash($password, true); $customerModelData = $customerRepositoryInterface->getById($customer_id); $customerSecure = $customerRegistry->retrieveSecureData($customer_id); // 生成客户hash密码 对象 $customerSecure->setRpToken(null); $customerSecure->setRpTokenCreatedAt(null); $customerSecure->setPasswordHash($password_hash); // 设置hash 密码 $customerRepositoryInterface->save($customerModelData,$password_hash);