Working with clients in Magento brings numerous challanges and recently one of our clients came up with such an issue where his customer accounts got hacked and he wanted us to generate new passwords and Email them to customers from his Magento store.
Unfortunately Magento stores get hacked sometime due to reasons such as installation of buggy Magento extensions, using an outdated version or many more you even don’t know the reason behind. In our case, Using Magento functions, this has to be done programmatically to save the hassle of doing it manually for each user. All we require is to create a custom code to generate new passwords for all registered users and send them in Email programmatically.
<?php ini_set('display_errors',true); include 'app/Mage.php'; Mage::setIsDeveloperMode(true); Mage::app(); try { $collection = Mage::getResourceModel('customer/customer_collection'); /* Group Filter For particulor Group of customer */ /* $collection->addFieldToFilter('group_id',4); */ foreach ($collection as $customer) { $customer->setForceConfirmed(true); $sendPassToEmail = true; $customer->setPassword($customer->generatePassword()); $customer->save(); $customer->sendNewAccountEmail('registered', '', $customer->getStoreId()); echo "Email :".$customer->getEmail(); } } catch(Exception $e) { Mage::log($e->getMessage(),null,"resetpasswd.log",true); }
Voila, implementing the above code, passwords would be instantaneously generated and Emailed to the desired customers. Now you are having a much faster solution to apply password changes for large scale customers. Let me know if you have any questions through commenting. Also your suggestions and feedback are always welcomed.
MongoDB is a popular NoSQL database that offers flexibility and scalability when handling modern web…
In NodeJS, callbacks empower developers to execute asynchronous operations like reading files, handling requests, and…
Hello Magento Friends, In today’s blog, we will learn How to Show SKU in Order…
The "Buy Now" and "Add to Cart" buttons serve as the primary call-to-action (CTA) elements…
Hello Magento Friends, In Magento 2, the checkout process allows customers to choose multiple shipping…
If you are a Shopify admin, using a Shopify Balance Account for your business revenue…