Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8907799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:00:35+00:00 2026-06-15T03:00:35+00:00

We have been trying to modify the Customer.php file ( import/export ) to get

  • 0

We have been trying to modify the Customer.php file ( import/export ) to get it to send out the new account details automatically as it imports the customers from a CSV file.

We are working in the right area as we dropped a simple mail() call which was called (we received the emails) for every new row. The problem arises when trying to get it to generate a new random password and send out the new account details – it never sends any mail and we cannot figure out why! Code follows ( Edited from app/code/local/Mage/ImportExport/Model/Import/Entity/Customer.php )

 /**
 * Update and insert data in entity table.
 *
 * @param array $entityRowsIn Row for insert
 * @param array $entityRowsUp Row for update
 * @return Mage_ImportExport_Model_Import_Entity_Customer
 */
protected function _saveCustomerEntity(array $entityRowsIn, array $entityRowsUp)
{
    if ($entityRowsIn) {
        $this->_connection->insertMultiple($this->_entityTable, $entityRowsIn);

          // BEGIN: Send New Account Email          
          $cust = Mage::getModel('customer/customer');
          $cust->setWebsiteId(Mage::app()->getWebsite()->getId());              
          foreach($entityRowsIn as $idx => $u){
            // Failed
            $cust->loadByEmail($u['email']);
            $cust->setConfirmation(NULL);
            $cust->setPassword($cust->generatePassword(8));
            $cust->save();
            $cust->sendNewAccountEmail();
            //$cust->sendPasswordReminderEmail(); // this call doesnt work either
          }
          // END: Send New Account Email

    }
    if ($entityRowsUp) {
        $this->_connection->insertOnDuplicate(
            $this->_entityTable,
            $entityRowsUp,
            array('group_id', 'store_id', 'updated_at', 'created_at')
        );
    }
    return $this;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:00:36+00:00Added an answer on June 15, 2026 at 3:00 am

    Inorder to improve performance magento ‘caches’ object, so when trying to load an object in a loop you either need to load a new instance or call it reset() method

    $website_id = Mage::app()->getWebsite()->getId();       
    foreach($entityRowsIn as $idx => $u){
        $cust = Mage::getModel('customer/customer');
        $cust->setWebsiteId($website_id);
        $cust->loadByEmail($u['email']);
        $cust->setPassword($cust->generatePassword(8));
        $cust->save();
        $cust->sendNewAccountEmail();  // if you are getting 2 email then remove this line
    }
    

    If you are load a large number of customers then you may run in to memory issues and my need to look a other technique using reset()

    If this code is being run from the Administration section of Magento then you will need to make sure that you set the correct Website ID ( Mage::app()->getWebsite()->getId() will return the incorrect one ).

    From the front end this code will work fine but for Admin work you should use ‘1’ or whatever your Front end websites ID is as the getId() method was returning ‘0’ in the Admin area! Small gotcha but had me going for hours!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to figure out how to modify my query to get
I am new with html and javascript. I have been trying to modify the
I have been trying to edit the jquery buttons in order to modify them
Have been trying to encrypt an xml file to a string so that I
I have been trying to get up to speed on Named Pipes this week.
I have been trying to get Qt X11 cross compiled for PowerPC for a
I am trying to modify a registry key that I have been told controls
I have been trying to modify HTML tag elements, I have a huge list
I have been trying to make a method for adding new elements in an
I've been trying to modify a Google charts example in order to have three

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.