<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$email = $_REQUEST['email'];
require_once ('../app/Mage.php');
Mage::app();
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
->loadByEmail($email);
//print_r($customer);
if ($customer->getId()) {
try {
$newResetPasswordLinkToken = Mage::helper('customer')->generateResetPasswordLinkToken();
$customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
$customer->setStoreId(Mage::app()->getStore()->getId());
$customer->sendPasswordResetConfirmationEmail();
$response['response'] = "success";
$response['message']="Password Reset Link Has Been Sent to Your Email Please Check, Your Mail Box!";
echo json_encode($response);
} catch (Exception $exception) {
Mage::log($exception);
}
}else{
$response['response'] = "failed";
$response['message']="Please Enter a Valid Email!";
echo json_encode($response);
}
?>
&#13;
答案 0 :(得分:0)
最近我工作忘记密码magento api它工作正常但很难我发现我必须将我的忘记密码文件名保存到index.php。制作一个api文件夹并使用index.php的名称保存它
<?php
if(!empty($_REQUEST['email']))
{
$yourCustomerEmail=$postcode = $_REQUEST['email'];
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
->loadByEmail($yourCustomerEmail);
//echo $customer->getId();
if ($customer->getId()) {
try {
$newResetPasswordLinkToken = Mage::helper('customer')->generateResetPasswordLinkToken();
$customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
$customer->sendPasswordResetConfirmationEmail();
$result = array('action'=> 'send','statuscode'=> '200');
echo json_encode($result);
} catch (Exception $exception) {
//echo "Exception";
Mage::log($exception);
}
}
else
{
$result = array('action'=> 'failed','statuscode'=> '300');
echo json_encode($result);
}
}
else
{
$result = array('action'=> 'failed','statuscode'=> '300');
echo json_encode($result);
}
?>