Sql Query To Change All Customers (Users) To Different Company Id?

Hi



I have thousands of customers imported into my new 4.2.4 cart who have the wrong company number.



Can anyone advise me of what query I need to run in phpmyadmin to change all company_id entries in Table: cscart_users from 0 (zero) to 1 (one) ?



Thanks.



T.

[quote name='TommyUK' timestamp='1431539769' post='214291']

I have thousands of customers imported into my new 4.2.4 cart who have the wrong company number.



Can anyone advise me of what query I need to run in phpmyadmin to change all company_id entries in Table: cscart_users from 0 (zero) to 1 (one) ?

[/quote]



Hi,



Please use the following query:



UPDATE `cscart_users` SET `company_id` = 1 WHERE `company_id` = 0;




best regards,

WSA team

[quote name=‘Damir (WSA-team)’ timestamp=‘1431550283’ post=‘214300’]

Hi,



Please use the following query:


<br />
UPDATE `cscart_users` SET `company_id` = 1 WHERE `company_id` = 0;<br />

```<br />
<br />
best regards,<br />
WSA team<br />
[/quote]<br />
<br />
Excellent, many thanks <img src="upload://rA9Qa8gnUPZzRZRdI8kt3dpjkrs.png" class="bbc_emoticon" alt=":)"><br />
<br />
T.

Be careful, you are not distinguishing between customers and admins. Company 0 means shared versus specific company.

[quote name='tbirnseth' timestamp='1431669549' post='214441']

Be careful, you are not distinguishing between customers and admins. Company 0 means shared versus specific company.

[/quote]



Hi,



Not quite sure what you mean.



I only have one company - ID = 1 - does that matter?

it should not create problem if you have 1 store front, but if you already executed first query, please use this one:

UPDATE `cscart_users` SET `company_id` = 1 WHERE `company_id` = 0 AND `user_type` = 'C';



it would set back company_id to customers only.



best regards,

WSA team

[quote name='Damir (WSA-team)' timestamp='1431686476' post='214483']

it should not create problem if you have 1 store front, but if you already executed first query, please use this one:

UPDATE `cscart_users` SET `company_id` = 1 WHERE `company_id` = 0 AND `user_type` = 'C';



it would set back company_id to customers only.



best regards,

WSA team

[/quote]



Thanks,Damir.



On checking in phpmyadmin, there is only one user under UserType A, which is the site Admin. There is only one Admin and only one storefront. There will not be any more storefronts.



Does the company_id still need to be changed to 0 for him? If so, can you explain why?



Thanks.

[quote][color=#282828][font=arial, verdana, tahoma, sans-serif]On checking in phpmyadmin, there is only one user under UserType A, which is the site Admin. There is only one Admin and only one storefront. There will not be any more storefronts.[/font][/color]



[color=#282828][font=arial, verdana, tahoma, sans-serif]Does the company_id still need to be changed to 0 for him? If so, can you explain why?[/font][/color][/quote]



in this case, there is nothing to do else

the single admin you have is super admin and it should have company_id = 0



best regards,

WSA team

Ok, thanks :)

you’re welcome :-)

Curious what the original problem was that was trying to be solved by changing company_id of users?

Storefront was Company id=1. Customers and orders were imported using a popular third-party service, as Company id=0

And the problem was? company_id=0 means “all companies”.

So if you had one storefront they'd be part of that store and if you had mulitple, they'd be part of all stores.



There is also something called “simple company” that emulates behavior of the old PRO edition for single storefront stores. It too leaves company_id==0 meaning all stores or the one store.



Just curious on what the actual problem was or whether it was something you noticed and went off to “fix”.

After the import none of the categories were visible in the menu. Changing them to company 1 fixed that.

Plus no customers were recognised in password reminder until they were changed to company 1, hence my initial request.

[quote name='TommyUK' timestamp='1431726879' post='214559']

Plus no customers were recognised in password reminder until they were changed to company 1, hence my initial request.

[/quote]

Sorry, what is “password reminder”? Is this the notice that password has expired? If so, then this is definitely a bug in the core cart and should be reported as such. Customers with company_id == 0 should behave exactly the same as company_id == 1 when only a single storefront is configured.



The category company_id must match the product company_id otherwise the category will appear as if it contains no products and will then generally be hidden.

Password reminder is for customers on frontend. A customer tried to login but wasn't recognised. Password reminder didn't work either as customer not recognised. Changing customers (users) to company id 1 meant they could then use password reminder (as passwords not imported from old cart)

I think you should report this as a bug in bugtracker. While you may have resolved the issue, I believe there is a fundamental problem.