PHP dev
PHP dev

Reputation: 420

Create and send email to customer reset password link programmatically in magento

How to create a reset password link in magento and then send the mail to the corresponding customer.I have referred this link:

    1)http://stackoverflow.com/questions/19034753/magento-customer-password-reset-email

But i don't know what is going inside that code.So kindly answer to solve this.I want to done it manually(programmatically)

Upvotes: 5

Views: 6031

Answers (1)

Javier C. H.
Javier C. H.

Reputation: 2123

I think something like this should work:

        /** @var $customer Mage_Customer_Model_Customer */
        $customer = Mage::getModel('customer/customer')
            ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
            ->loadByEmail($yourCustomerEmail);
        if ($customer->getId()) {
            try {
                $newResetPasswordLinkToken =  Mage::helper('customer')->generateResetPasswordLinkToken();
                $customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
                $customer->sendPasswordResetConfirmationEmail();
            } catch (Exception $exception) {
                Mage::log($exception);
            }
        }

Upvotes: 12

Related Questions