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?

1

Here is the solution. Thanks to In case of multiple deletion, use below 2 query. note that run these SQL in same order as i have written here. 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 
AND FOR sales_flat_order_grid Table

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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