Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have found where is the problem to saving customer. whenever we load the customer by <code>loadByEmail</code> function we must set website id to load customer otherwise customer save raise the exception <code>Customer website ID must be specified when using the website scope</code>. so I have made following changes to set website id when creating customer.</p> <pre><code>if ($detail-&gt;ContactEmail &amp;&amp; $detail-&gt;ContactName != '' &amp;&amp; filter_var($detail-&gt;ContactEmail, FILTER_VALIDATE_EMAIL)) { $customer = Mage::getModel('customer/customer')-&gt;setWebsiteId(1); $customer-&gt;loadByEmail($detail-&gt;ContactEmail); /* changed line */ /* * Check if the email exist on the system. * If YES, it will not create a user account. */ if (!$customer-&gt;getId()) { //setting data such as email, firstname, lastname, and password $customer-&gt;setEmail($detail-&gt;ContactEmail); $name = preg_split('/\s+/', trim($detail-&gt;ContactName)); if (count($name) == 1) { $customer-&gt;setFirstname($name[0]); $customer-&gt;setLastname($name[0]); } else { $customer-&gt;setFirstname($name[0]); $customer-&gt;setLastname($name[1]); } $customer-&gt;setcontactJobTitle($detail-&gt;ContactJobTitle); $customer-&gt;setcontactSeqNo($detail-&gt;ContactSeqNo); $customer-&gt;setdebtorAccNo($detail-&gt;DebtorAccNo); $customer-&gt;setdebtorApiKey($debtorAPI); $customer-&gt;setStoreId(Mage::app()-&gt;getStore('default')-&gt;getId()); $customer-&gt;setPassword($customer-&gt;generatePassword($passwordLength)); } try { //the save the data and send the new account email. $customer-&gt;save(); $customer-&gt;setConfirmation(null); $customer-&gt;setWebsiteId(1); /* changed line */ $customer-&gt;save(); $customer-&gt;sendNewAccountEmail(); $customerCount[] = $i; //echo 'contact added'; } catch (Exception $e) { //echo 'contact not added'; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload