Setting user attributes using a tools file in 5.7.

I'm building a new version (using of an existing site, which current version is using and has about 300 users. I migrated users successfully by exporting and importing the Users table via phpMyAdmin and modifying the data order to match 5.7. Now I'm trying to get the user attributes migrated, too, so that the users would have as smooth transition as possible.

I export/imported the UserSearchIndexAttributes table to the new site so that I got the attribute values there and now I need to get those attributes set correctly (i.e. into AttributeKeys, -Types and -Values tables)... My idea is to create a file into tools directory so that by running it I would loop through all users, take the needed attribute's value from the UserSearchIndexAttributes table and use UserInfo setAttribute() function to add it. I've managed to print the UserInfo object of the selected user and also the value queried from db, but the $ui->setAttribute('my_handle','value-from-db') returns error "Call to a member function setAttribute() on a non-object" even though I could successfully print_r($ui) one line before? Here's my code for the tools file (with hard-coded uID to test with so no looping through users yet):
namespace Concrete\Core\User;
use Loader;
$db = Loader::db();
$q = $db->Execute('SELECT ak_subscribe_bu FROM UserSearchIndexAttributes WHERE uID = 11');
$row = $q->fetchRow();
echo VALUE: '.$row['ak_subscribe_bu'].'<br>';
$ui = UserInfo::getByID(11);
$ui->setAttribute('ak_subscribe_bu', $row['ak_subscribe_bu']);

So both the echo and print_r give expected results so $ui isn't non-object at least to my understanding... Any ideas why the setAttribute doesn't work? Or do you have other ideas how I could achieve this? I don't yet understand the 5.7. system much at all so maybe I'm trying this in a totally wrong way.. Site cache is off btw.

Any help appreciated,

View Replies:
MrKDilkington replied on at Permalink Reply
Hi patej,

I am afraid I don't know of a solution to your problem.

I am commenting because I think others will be interested in your experience with migrating a site with a large number of users.
daenu replied on at Permalink Reply
There will be an add-on online this week or at the beginning of the next week for exactly that purpose.
patej replied on at Permalink Reply
Great news, thanks! ...our migration (or actually the site redesign) has postponed "a bit" so this is still valid for us. :)

Could you post here the link to the addon once it's published?
daenu replied on at Permalink Reply
Good to hear!
Sure I will post the link as soon as it's online.