Create and update rp_token in Magento 2
I'm trying to create customer account manually in my custom module. Customer account is getting created successfully and welcome email is sent to the new customer using $customer->sendNewAccountEmail();
. But On clicking the forgot password link I found the rp_token is missing in the template.
If we're programmatically creating customer_entity table is not updating. If the customer is registered via Magento default create account page in the frontend the rp_token is updating successfully.
How to create and insert rp_token on creating customer account programmatically? See my customer creation code below
$orderArray = $this->getRequest()->getPost('order');
$sellerComment = $orderArray['comment']['customer_note'];
$id = $this->convert->_getSession()->getCustomerId();
$websiteId = $this->_storeManager->getStore()->getId();
$customerEmail = $orderArray['account']['email'];
$customerFirstName = $orderArray['billing_address']['firstname'];
$customerLastName = $orderArray['billing_address']['lastname'];
$customerCompany = $orderArray['billing_address']['company'];
$customerCity = $orderArray['billing_address']['city'];
$customerCountryId = $orderArray['billing_address']['country_id'];
$customerPostcode = $orderArray['billing_address']['postcode'];
$customerTelephone = $orderArray['billing_address']['telephone'];
$customerFax = $orderArray['billing_address']['fax'];
$customerStreetArray = $orderArray['billing_address']['street'];
$customerStreet = implode(',', $customerStreetArray);
$customerID = '';
/* if new customer */
if ($id == 0) {
$chars = MagentoFrameworkMathRandom::CHARS_LOWERS
. MagentoFrameworkMathRandom::CHARS_UPPERS
. MagentoFrameworkMathRandom::CHARS_DIGITS;
$password = $this->mathRandom->getRandomString(10, $chars);
$customer = $this->_customerFactory->create();
$customer->setWebsiteId($websiteId);
$customer->setEmail($customerEmail);
$customer->setFirstname($customerFirstName);
$customer->setLastname($customerLastName);
$customer->setPassword($password);
$customer->setForceConfirmed(true);
$customer->save();
$customerID = $customer->getId();
$address = $this->_addressFactory->create();
$address->setCustomerId($customer->getId())
->setFirstname($customerFirstName)
->setLastname($customerLastName)
->setCountryId($customerCountryId)
->setPostcode($customerPostcode)
->setCity($customerCity)
->setTelephone($customerTelephone)
->setFax($customerFax)
->setCompany($customerCompany)
->setStreet($customerStreet)
->setIsDefaultBilling('1')
->setIsDefaultShipping('1')
->setSaveInAddressBook('1');
$address->save();
$customer->sendNewAccountEmail();
}
magento2 customer-account email-templates password token
add a comment |
I'm trying to create customer account manually in my custom module. Customer account is getting created successfully and welcome email is sent to the new customer using $customer->sendNewAccountEmail();
. But On clicking the forgot password link I found the rp_token is missing in the template.
If we're programmatically creating customer_entity table is not updating. If the customer is registered via Magento default create account page in the frontend the rp_token is updating successfully.
How to create and insert rp_token on creating customer account programmatically? See my customer creation code below
$orderArray = $this->getRequest()->getPost('order');
$sellerComment = $orderArray['comment']['customer_note'];
$id = $this->convert->_getSession()->getCustomerId();
$websiteId = $this->_storeManager->getStore()->getId();
$customerEmail = $orderArray['account']['email'];
$customerFirstName = $orderArray['billing_address']['firstname'];
$customerLastName = $orderArray['billing_address']['lastname'];
$customerCompany = $orderArray['billing_address']['company'];
$customerCity = $orderArray['billing_address']['city'];
$customerCountryId = $orderArray['billing_address']['country_id'];
$customerPostcode = $orderArray['billing_address']['postcode'];
$customerTelephone = $orderArray['billing_address']['telephone'];
$customerFax = $orderArray['billing_address']['fax'];
$customerStreetArray = $orderArray['billing_address']['street'];
$customerStreet = implode(',', $customerStreetArray);
$customerID = '';
/* if new customer */
if ($id == 0) {
$chars = MagentoFrameworkMathRandom::CHARS_LOWERS
. MagentoFrameworkMathRandom::CHARS_UPPERS
. MagentoFrameworkMathRandom::CHARS_DIGITS;
$password = $this->mathRandom->getRandomString(10, $chars);
$customer = $this->_customerFactory->create();
$customer->setWebsiteId($websiteId);
$customer->setEmail($customerEmail);
$customer->setFirstname($customerFirstName);
$customer->setLastname($customerLastName);
$customer->setPassword($password);
$customer->setForceConfirmed(true);
$customer->save();
$customerID = $customer->getId();
$address = $this->_addressFactory->create();
$address->setCustomerId($customer->getId())
->setFirstname($customerFirstName)
->setLastname($customerLastName)
->setCountryId($customerCountryId)
->setPostcode($customerPostcode)
->setCity($customerCity)
->setTelephone($customerTelephone)
->setFax($customerFax)
->setCompany($customerCompany)
->setStreet($customerStreet)
->setIsDefaultBilling('1')
->setIsDefaultShipping('1')
->setSaveInAddressBook('1');
$address->save();
$customer->sendNewAccountEmail();
}
magento2 customer-account email-templates password token
please post your code for customer account creation
– Keyur Shah
2 days ago
@KeyurShah Please have a look at my updated question
– sreelakshmi
2 days ago
add a comment |
I'm trying to create customer account manually in my custom module. Customer account is getting created successfully and welcome email is sent to the new customer using $customer->sendNewAccountEmail();
. But On clicking the forgot password link I found the rp_token is missing in the template.
If we're programmatically creating customer_entity table is not updating. If the customer is registered via Magento default create account page in the frontend the rp_token is updating successfully.
How to create and insert rp_token on creating customer account programmatically? See my customer creation code below
$orderArray = $this->getRequest()->getPost('order');
$sellerComment = $orderArray['comment']['customer_note'];
$id = $this->convert->_getSession()->getCustomerId();
$websiteId = $this->_storeManager->getStore()->getId();
$customerEmail = $orderArray['account']['email'];
$customerFirstName = $orderArray['billing_address']['firstname'];
$customerLastName = $orderArray['billing_address']['lastname'];
$customerCompany = $orderArray['billing_address']['company'];
$customerCity = $orderArray['billing_address']['city'];
$customerCountryId = $orderArray['billing_address']['country_id'];
$customerPostcode = $orderArray['billing_address']['postcode'];
$customerTelephone = $orderArray['billing_address']['telephone'];
$customerFax = $orderArray['billing_address']['fax'];
$customerStreetArray = $orderArray['billing_address']['street'];
$customerStreet = implode(',', $customerStreetArray);
$customerID = '';
/* if new customer */
if ($id == 0) {
$chars = MagentoFrameworkMathRandom::CHARS_LOWERS
. MagentoFrameworkMathRandom::CHARS_UPPERS
. MagentoFrameworkMathRandom::CHARS_DIGITS;
$password = $this->mathRandom->getRandomString(10, $chars);
$customer = $this->_customerFactory->create();
$customer->setWebsiteId($websiteId);
$customer->setEmail($customerEmail);
$customer->setFirstname($customerFirstName);
$customer->setLastname($customerLastName);
$customer->setPassword($password);
$customer->setForceConfirmed(true);
$customer->save();
$customerID = $customer->getId();
$address = $this->_addressFactory->create();
$address->setCustomerId($customer->getId())
->setFirstname($customerFirstName)
->setLastname($customerLastName)
->setCountryId($customerCountryId)
->setPostcode($customerPostcode)
->setCity($customerCity)
->setTelephone($customerTelephone)
->setFax($customerFax)
->setCompany($customerCompany)
->setStreet($customerStreet)
->setIsDefaultBilling('1')
->setIsDefaultShipping('1')
->setSaveInAddressBook('1');
$address->save();
$customer->sendNewAccountEmail();
}
magento2 customer-account email-templates password token
I'm trying to create customer account manually in my custom module. Customer account is getting created successfully and welcome email is sent to the new customer using $customer->sendNewAccountEmail();
. But On clicking the forgot password link I found the rp_token is missing in the template.
If we're programmatically creating customer_entity table is not updating. If the customer is registered via Magento default create account page in the frontend the rp_token is updating successfully.
How to create and insert rp_token on creating customer account programmatically? See my customer creation code below
$orderArray = $this->getRequest()->getPost('order');
$sellerComment = $orderArray['comment']['customer_note'];
$id = $this->convert->_getSession()->getCustomerId();
$websiteId = $this->_storeManager->getStore()->getId();
$customerEmail = $orderArray['account']['email'];
$customerFirstName = $orderArray['billing_address']['firstname'];
$customerLastName = $orderArray['billing_address']['lastname'];
$customerCompany = $orderArray['billing_address']['company'];
$customerCity = $orderArray['billing_address']['city'];
$customerCountryId = $orderArray['billing_address']['country_id'];
$customerPostcode = $orderArray['billing_address']['postcode'];
$customerTelephone = $orderArray['billing_address']['telephone'];
$customerFax = $orderArray['billing_address']['fax'];
$customerStreetArray = $orderArray['billing_address']['street'];
$customerStreet = implode(',', $customerStreetArray);
$customerID = '';
/* if new customer */
if ($id == 0) {
$chars = MagentoFrameworkMathRandom::CHARS_LOWERS
. MagentoFrameworkMathRandom::CHARS_UPPERS
. MagentoFrameworkMathRandom::CHARS_DIGITS;
$password = $this->mathRandom->getRandomString(10, $chars);
$customer = $this->_customerFactory->create();
$customer->setWebsiteId($websiteId);
$customer->setEmail($customerEmail);
$customer->setFirstname($customerFirstName);
$customer->setLastname($customerLastName);
$customer->setPassword($password);
$customer->setForceConfirmed(true);
$customer->save();
$customerID = $customer->getId();
$address = $this->_addressFactory->create();
$address->setCustomerId($customer->getId())
->setFirstname($customerFirstName)
->setLastname($customerLastName)
->setCountryId($customerCountryId)
->setPostcode($customerPostcode)
->setCity($customerCity)
->setTelephone($customerTelephone)
->setFax($customerFax)
->setCompany($customerCompany)
->setStreet($customerStreet)
->setIsDefaultBilling('1')
->setIsDefaultShipping('1')
->setSaveInAddressBook('1');
$address->save();
$customer->sendNewAccountEmail();
}
magento2 customer-account email-templates password token
magento2 customer-account email-templates password token
edited 2 days ago
sreelakshmi
asked 2 days ago
sreelakshmisreelakshmi
11110
11110
please post your code for customer account creation
– Keyur Shah
2 days ago
@KeyurShah Please have a look at my updated question
– sreelakshmi
2 days ago
add a comment |
please post your code for customer account creation
– Keyur Shah
2 days ago
@KeyurShah Please have a look at my updated question
– sreelakshmi
2 days ago
please post your code for customer account creation
– Keyur Shah
2 days ago
please post your code for customer account creation
– Keyur Shah
2 days ago
@KeyurShah Please have a look at my updated question
– sreelakshmi
2 days ago
@KeyurShah Please have a look at my updated question
– sreelakshmi
2 days ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f257481%2fcreate-and-update-rp-token-in-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f257481%2fcreate-and-update-rp-token-in-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
please post your code for customer account creation
– Keyur Shah
2 days ago
@KeyurShah Please have a look at my updated question
– sreelakshmi
2 days ago