Manually update order- and user IDs

My client his business will migrate from paper/wordperfect docs to cs-cart. He has 10 years of crm history which needs to be imported into cs-cart backoffice.

I already tested a few clients in the current cart software. They got user_ids from #1 to #11. I've tested orders too. Got six orders; #1 - #6 so far. These are real customers/orders.



I've reached a point where I want to migrate all customers to cs-cart. Including the eleven user profiles. They need to be updated to a higher number (#1272 - #1282).

Order history is a different story. We don't import the order history. I only need the current six orders to be updated to order_ids #4328 - #4333.



How would I do that? I guess this is only doable by manually updating the responsible tables by making queries?

Maybe empty all data and start over? But how will I be certain about customers getting the correct user_ids? Since these are all primary keys I can't import them.

I'm not understanding clearly your current position.



You want to create user profiles (such as administrators) as well as customer accounts?



You need the user profiles to have ID's #1272 to #1282.



You need customer profiles to have ID's #1 to #1271?



You need to only import 6 orders, assigned to order ID's 4328-4333? To which account will these be assigned to?



You can easily import this all of data via CSV or SQL.

Forget the orders. I will create those again.

About the users. Yes, I know I can import a list of new users via CSV or SQL query. But those imported users need to have the same unique IDs as the offline data of my client. I don't think one imports the user_id field, instead it's created by the system since it's a Primary Key. So I don't have control of which user gets which number. Correct?

Yes, you can import these directly into the database via SQL or CSV imports with your required ID's.



Alternatively, once you install, the admistrator account will be assigned to user_id 1. You could then edit this users relevent user_id field value in the tables - cscart_users, cscart_user_data and cscart_user_profiles to #1272, thus the 'first' administrator account has ID #1272 and any further users are assigned from 1273 onwards due to the 'auto increment' value, so you could import via CSV to have your 10 user profiles occupy ID #1273-1282 and achieve your #1272-#1282 goal.



I'm sure there are a million other ways to do this but those are the two techniques I have used.

You can't have the primary administrtor be anything other than user_id 1. If you do, you will never have access to things like group admin permissions, etc. which are restricted to user_id == 1.

[quote name='tbirnseth' timestamp='1359066696' post='153580']

You can't have the primary administrtor be anything other than user_id 1. If you do, you will never have access to things like group admin permissions, etc. which are restricted to user_id == 1.

[/quote]

I thought this was controlled by the 'is_root' = Y value? Maybe not…

Hmm… Possibly. But if I recall (could have changed since I looked) to get to usergroups for admins still required user_id == 1.

Happy to be wrong on this one… Would open up a lot of options if true.

There are a lot of instances of 'is_root', such as:


if (AREA == 'A' && (!empty($_SESSION['auth']['usergroup_ids']) || (!empty($_SESSION['auth']['company_id']) && $_SESSION['auth']['is_root'] != 'Y'))) {
fn_define('RESTRICTED_ADMIN', true);
}

Just breaking this up to parse it out…

if in Admin

and

there are usergroups defined for the user OR (user is a vendor or a supplier AND is_root equals N)

then

they are restricted



So if the admin is in a usergroup, they are restricted

OR

they are a vendor or supplier (or operating in the context of an Ultimate storefront) AND they are not designated as a root user they are restricted.



Kind of convoluted, but the fact that is_root must be Y is valid but there are other reasons why the user wouldn’t have primary admin rights.



Allso take a look at the function fn_is_restricted_admin() in fn.users.php. Even more scenarios, but only seems to be used when deleting a user…



Well, this was fun! I’m sick tonight so just sitting on the couch. Good way to kill some time. Looks like it’s all still evolving… But Ijust tried it and it works. Too bad there’s no way to set it in the UI! :-)

[quote name='hans' timestamp='1359034703' post='153530']

My client his business will migrate from paper/wordperfect docs to cs-cart. He has 10 years of crm history which needs to be imported into cs-cart backoffice.

I already tested a few clients in the current cart software. They got user_ids from #1 to #11. I've tested orders too. Got six orders; #1 - #6 so far. These are real customers/orders.



I've reached a point where I want to migrate all customers to cs-cart. Including the eleven user profiles. They need to be updated to a higher number (#1272 - #1282).

Order history is a different story. We don't import the order history. I only need the current six orders to be updated to order_ids #4328 - #4333.



How would I do that? I guess this is only doable by manually updating the responsible tables by making queries?

Maybe empty all data and start over? But how will I be certain about customers getting the correct user_ids? Since these are all primary keys I can't import them.

[/quote]



You can try create another field in [color=#ff0000]cscart_users[/color] at the end for ex: [color=#ff0000]wp_user_id[/color] and track this id and do the same for the orders.



If you like i can help, PM me.



I hope this information will help you.





Valentin

Today my client told me that many of his clients aren't active (or alive :S) anymore, they don't need to be imported. To overcome the issue of creating fragmented user_ids one would have to import dummy accounts. I don't like that.



That last option seems most perfect. But it will need huge code-changing, correct? Many files call the user_id field.

[quote name='hans' timestamp='1359109472' post='153635']

Today my client told me that many of his clients aren't active (or alive :S) anymore, they don't need to be imported. To overcome the issue of creating fragmented user_ids one would have to import dummy accounts. I don't like that.



That last option seems most perfect. But it will need huge code-changing, correct? Many files call the user_id field.

[/quote]

No, depand of your client requests, what do you need to do with [color=#ff0000]wp_user_id[/color], where and why you are using?





Valentin

Well, everywhere where user_id is shown (profile, checkout, invoices(print,pdf,e-mail), etc.) I need to substitute [color=#ff0000]user_id [/color]with [color=#ff0000]wp_user_id [/color]systemwide I guess.

profile, checkout, invoices(print,pdf,e-mail), etc. can use without any problem user_id.



Please PM me if you wish me to help you ;)





Valentin

[quote]

You can try create another field in [color=#ff0000]cscart_users[/color] at the end for ex: [color=#ff0000]wp_user_id[/color] and track this id and do the same for the orders.

[/quote]

The proper and portable way to do this is to use the cscart_user_data table and NOT modify the DB but instead have controllers/hooks that fetch the data appropriately.