Reputation: 3
I created a customer group
named corporate users
and i uploaded bulk emails into that group. Now i need to send auto generated passwords to all users under corporate users
user group. Id of that user group is "4".
So far i tried with http://www.magentocommerce.com/boards/viewthread/67065/
But this one didn't worked me. Did any one went through these kind of issues.
Any solution is really appreciated !!
Upvotes: 0
Views: 2920
Reputation: 23205
If this doesn't work directly, it should be a start.
<?php
ini_set('display_errors',true);
include 'app/Mage.php';
Mage::setIsDeveloperMode(true);
Mage::app();
$coll = Mage::getResourceModel('customer/customer_collection');
// or $coll = Mage::getModel('customer/customer')->getCollection();
/* @var $coll Mage_Customer_Model_Resource_Customer_Collection */
/* or Mage_Customer_Model_Entity_Customer_Collection < CE1.6 */
$coll->addFieldToFilter('group_id',4);
/*
* Use the SPL IteratorAggregate implementation of Magento collections.
* @var $customer Mage_Customer_Model_Customer
* @see Mage_Adminhtml_CustomerController->saveAction()
*/
foreach ($coll as $customer) {
$customer->setForceConfirmed(true);
$sendPassToEmail = true;
$customer->setPassword($customer->generatePassword());
$customer->save();
$customer->sendNewAccountEmail('registered', '', $customer->getStoreId());
}
Upvotes: 3