0

My website got hacked and all the customers were deleted, but the orders are still here.

I imported back the customers by CSV, but the orders are no longer assigned/linked to them. The only commun point is the email address in the orders details and the email address in customers accounts.

I need to know how I can assign again orders to customers in the database. Is it possible to find a way to link them again using the email?

3 Answers 3

1

Here is the solution. In case of multiple deletion, use those 2 sql queries. First sql query will link orders to customers, and second query will show the orders in the customers account (orders tab)

UPDATE sales_flat_order as SFO  
INNER JOIN customer_entity as C  
ON C.email = SFO.customer_email  
SET SFO.customer_id = C.entity_id  
WHERE SFO.customer_is_guest = 0 

UPDATE sales_flat_order_grid as SFOG  
INNER JOIN sales_flat_order as SFO  
ON SFO.entity_id = SFOG.entity_id  
SET SFOG.customer_id = SFO.customer_id
0

It looks like this query worked, and I can see the client in the order and click on his name to go see his info.

UPDATE sales_flat_order as SFO INNER JOIN customer_entity as C on C.email = SFO.customer_email SET SFO.customer_id = C.entity_id WHERE SFO.customer_is_guest = 0

But when I go to the client's info, Orders Tab, there are no orders.

0

it's return the Error in query (1064): Syntax error near 'FOR sales_flat_order_grid Table' at line 6strong text

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.