<blockquote>
<p>Users will be imported without passwords. Would this provide some kind of security risk, for example, someone being able to log in with empty password?</p>
</blockquote>
<p>I don't think the imported users will be able to login at all without a password.</p>
<blockquote>
<p>Setting new passwords for users - would I need to write custom module to send password reset form to each imported user? Would not sending 5000 emails at once choke Craft - maybe I should use tasks for that?</p>
</blockquote>
<p>I handled this by setting a message on the login and forgot password pages, skipping the need to send an email. Something like &quot;Our systems were upgraded on 10-20-2020, if you've not logged in since then you'll need to reset your password first&quot;.</p>
<blockquote>
<p>Addresses - do i need to write some custom plugin for importing adddress data along with basic user data like email? I didnt saw any fields for setting up user address when i tested importing users using feedme. Did someone managed to tackle this issue in the past?</p>
</blockquote>
<p>Yes, you will need to use a custom module/plugin and listen to feedme events and handle address import with your code.</p>
<p>Something like:</p>
<pre><code> Event::on(Process::class, Process::EVENT_STEP_AFTER_ELEMENT_SAVE, function (FeedProcessEvent $event) {
   /// your code here dealing with $event-&gt;feedData;         
});
</code></pre>

CC BY-SA 4.0
2020-11-10T17:50:10.853Z
2020-11-10T17:50:10.853Z
sparkalow
<p>I had to import user data from Prestashop into Craft Commerce v4 and came up with this solution, which uses a Yii module.</p>
<pre><code>// Create address elements from feed-me import
Event::on(
    Process::class, 
    Process::EVENT_STEP_AFTER_ELEMENT_SAVE, 
    function(FeedProcessEvent $event) {
        $addressElement = $this-&gt;_createAddress($event-&gt;contentData, $event-&gt;element-&gt;id);
});
</code></pre>
<p>I then adapted a function I found in the UpdateController in Commerce 4 that is used to update existing Commerce 3 installations:</p>
<pre><code>private function _createAddress($data, $id): Address
    {

        $address = new Address();
        $address-&gt;title = 'Meine Adresse';

        // set the owner (user) of the address element
        if (isset($id)) {
            $address-&gt;ownerId = $id;
        }

        $address-&gt;addressLine1 = $data['addressline1'];
        if (isset($data['addressline2'])) {
            $address-&gt;addressLine2 = $data['addressline2'];
        }

        $address-&gt;countryCode = 19;

        switch ($data['countryid']) {
            case '19':
                $address-&gt;countryCode = 'CH';
                break;
            case '1':
                $address-&gt;countryCode = 'DE';
                break;
            case '2':
                $address-&gt;countryCode = 'FR';
                break;
            case '130':
                $address-&gt;countryCode = 'LI';
                break;
            case '10':
                $address-&gt;countryCode = 'IT';
                break;
        }

        $address-&gt;administrativeArea = null;

        $address-&gt;postalCode = $data['postalcode'];
        $address-&gt;locality = $data['city'];
        $address-&gt;dependentLocality = '';

        if ($data['firstname'] || $data['lastname']) {
            $address-&gt;fullName = implode(' ', array_filter([$data['firstname'], $data['lastname']]));
        }

        if (isset($data['company'])) {
            $address-&gt;organization = $data['company'];
        }

        $address-&gt;dateCreated = DateTimeHelper::toDateTime($data['dateupdate']);
        $address-&gt;dateUpdated = DateTimeHelper::toDateTime($data['postalcode']);
        Craft::$app-&gt;getElements()-&gt;saveElement($address, false, false, false);

        return $address;
    }
</code></pre>
<p>You might not need all the code in this function but you will get the idea.</p>

CC BY-SA 4.0
2022-11-09T07:49:50.580Z
2022-11-09T07:49:50.580Z
MisterMike
<p>I have few questions about importing users into Craft CMS using feedme. These users would be also Craft Commerce customers.</p>
<ul>
<li>Users will be imported without passwords. Would this provide some kind of security risk, for example, someone being able to log in with empty password?</li>
<li>Setting new passwords for users - would I need to write custom module to send password reset form to each imported user? Would not sending 5000 emails at once choke Craft - maybe I should use tasks for that?</li>
<li>Addresses - do i need to write some custom plugin for importing adddress data along with basic user data like email? I didnt saw any fields for setting up user address when i tested importing users using feedme. Did someone managed to tackle this issue in the past?</li>
</ul>

CC BY-SA 4.0
2023-02-06T11:19:46.960Z
I have a problem with Feed Me. when i added the URL's of File in Feed URL, I can't connect the Data and I can't see the Change. what is the Problem?
eli sadeghi
<plugin-craftcommerce><plugin-feedme>
Feedme plugin - importing users into craft commerce
# Feedme plugin - importing users into craft commerce

(Asked by: username_0 on 2020-11-09)

I have few questions about importing users into Craft CMS using feedme. These users would be also Craft Commerce customers.

* Users will be imported without passwords. Would this provide some kind of security risk, for example, someone being able to log in with empty password?
* Setting new passwords for users - would I need to write custom module to send password reset form to each imported user? Would not sending 5000 emails at once choke Craft - maybe I should use tasks for that?
* Addresses - do i need to write some custom plugin for importing adddress data along with basic user data like email? I didnt saw any fields for setting up user address when i tested importing users using feedme. Did someone managed to tackle this issue in the past?

**Tags:** plugin-craftcommerce, plugin-feedme

> **Comments:**
> **username_1**: I have a problem with Feed Me. when i added the URL's of File in Feed URL, I can't connect the Data and I can't see the Change. what is the Problem?  

---

## 2 answers

### Answer by username_2 on 2020-11-10. Score: 2

Users will be imported without passwords. Would this provide some kind of security risk, for example, someone being able to log in with empty password?

I don't think the imported users will be able to login at all without a password.

Setting new passwords for users - would I need to write custom module to send password reset form to each imported user? Would not sending 5000 emails at once choke Craft - maybe I should use tasks for that?

I handled this by setting a message on the login and forgot password pages, skipping the need to send an email. Something like "Our systems were upgraded on 10-20-2020, if you've not logged in since then you'll need to reset your password first".

Addresses - do i need to write some custom plugin for importing adddress data along with basic user data like email? I didnt saw any fields for setting up user address when i tested importing users using feedme. Did someone managed to tackle this issue in the past?

Yes, you will need to use a custom module/plugin and listen to feedme events and handle address import with your code.
Something like:
 Event::on(Process::class, Process::EVENT_STEP_AFTER_ELEMENT_SAVE, function (FeedProcessEvent $event) {
   /// your code here dealing with $event->feedData;         
});


---

### Answer by username_3 on 2022-11-09. Score: 1

I had to import user data from Prestashop into Craft Commerce v4 and came up with this solution, which uses a Yii module.
// Create address elements from feed-me import
Event::on(
    Process::class, 
    Process::EVENT_STEP_AFTER_ELEMENT_SAVE, 
    function(FeedProcessEvent $event) {
        $addressElement = $this->_createAddress($event->contentData, $event->element->id);
});

I then adapted a function I found in the UpdateController in Commerce 4 that is used to update existing Commerce 3 installations:
private function _createAddress($data, $id): Address
    {

        $address = new Address();
        $address->title = 'Meine Adresse';

        // set the owner (user) of the address element
        if (isset($id)) {
            $address->ownerId = $id;
        }

        $address->addressLine1 = $data['addressline1'];
        if (isset($data['addressline2'])) {
            $address->addressLine2 = $data['addressline2'];
        }

        $address->countryCode = 19;

        switch ($data['countryid']) {
            case '19':
                $address->countryCode = 'CH';
                break;
            case '1':
                $address->countryCode = 'DE';
                break;
            case '2':
                $address->countryCode = 'FR';
                break;
            case '130':
                $address->countryCode = 'LI';
                break;
            case '10':
                $address->countryCode = 'IT';
                break;
        }

        $address->administrativeArea = null;

        $address->postalCode = $data['postalcode'];
        $address->locality = $data['city'];
        $address->dependentLocality = '';

        if ($data['firstname'] || $data['lastname']) {
            $address->fullName = implode(' ', array_filter([$data['firstname'], $data['lastname']]));
        }

        if (isset($data['company'])) {
            $address->organization = $data['company'];
        }

        $address->dateCreated = DateTimeHelper::toDateTime($data['dateupdate']);
        $address->dateUpdated = DateTimeHelper::toDateTime($data['postalcode']);
        Craft::$app->getElements()->saveElement($address, false, false, false);

        return $address;
    }

You might not need all the code in this function but you will get the idea.


---

