Unfortunately/mistakenly a customer was deleted. but from this customer id purchased lots of item. So I want add new customer with previous id. Please help me.

  • Please create a new customer and change this customer id from customer_entity table . But this is not a good practice – Purushotam Sharma Mar 4 '18 at 8:22
  • You should also change the other relation of this table also – Purushotam Sharma Mar 4 '18 at 8:26
  • already changed customer_entity but previous order not loaded yet. – Anwar Mar 4 '18 at 8:43
  • Have you changed the customer details in sales_flat_order table? – Purushotam Sharma Mar 4 '18 at 8:45
  • no, I didn't change order table yet. – Anwar Mar 4 '18 at 8:55

If it is only related to order history, then I think you don't have to update customer_entity table. You have to create new customer and update that new customer_id in sales_flat_order table for that deleted customer's orders.

As you can see in core Magento to get order history of customer they use customer id filter in order collection, so once you will update the customer id in order table then user will be able to see his/her past orders. This is core code to fetch customer order history for reference:

   $orders = Mage::getResourceModel('sales/order_collection')
                ->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
                ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
                ->setOrder('created_at', 'desc')

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.