Refill UserSearchIndexAttributes table

Permalink
Hi,

I did a fresh import of 1200 users, but now the userID of the UserSearchIndexAttributes doesnt correspond with the userID in the users table anymore. I cleared the UserSearchIndexAttributes table but how do I refill it with the new data again ?

-edit
The import we wrote didnt update the userSearchIndexAttributes table by itself. I made a script that updates an user attribute with the same value as it was so it inserted it in to the userSearchIndex table.

Not a great way but it did the trick.

 
guyDesign replied on at Permalink Reply
Can you post the code?
nielsb85 replied on at Permalink Reply
This was a while ago. I don't have this code anymore. But If you have problems filling the user search index, then I think the next example should do the same trick, only way faster then the way I did it before.

$ul = new UserList();
$users = $ul->get(99999); 
foreach($users as $user)
{
       $user->reindex();
}



I think my old code was something like this: (I haven tested this and just wrote it quickly. so backup the database first ;))

$ul = new UserList();
        $users = $ul->get(99999);
        $attributeList = UserAttributeKey::getEditableList();
        foreach($users as $user)
        {
            foreach($attributeList as $attribute)
            {
                    $value = $user->getAttribute($attribute->akHandle);
                    $user->setAttribute($attribute->akHandle,$value);
            }
        }