Accidentally deleted customers Magento 1.9












1















We recently had BOTs setting up accounts on our website, 2000 or so.



We accidentally clicked delete all instead of delete all visible and lost about half of our accounts.



I have a database backup from a few weeks ago that I can use, what would be the best way to get the customers from the old database without effecting the customers that weren't deleted?










share|improve this question



























    1















    We recently had BOTs setting up accounts on our website, 2000 or so.



    We accidentally clicked delete all instead of delete all visible and lost about half of our accounts.



    I have a database backup from a few weeks ago that I can use, what would be the best way to get the customers from the old database without effecting the customers that weren't deleted?










    share|improve this question

























      1












      1








      1








      We recently had BOTs setting up accounts on our website, 2000 or so.



      We accidentally clicked delete all instead of delete all visible and lost about half of our accounts.



      I have a database backup from a few weeks ago that I can use, what would be the best way to get the customers from the old database without effecting the customers that weren't deleted?










      share|improve this question














      We recently had BOTs setting up accounts on our website, 2000 or so.



      We accidentally clicked delete all instead of delete all visible and lost about half of our accounts.



      I have a database backup from a few weeks ago that I can use, what would be the best way to get the customers from the old database without effecting the customers that weren't deleted?







      magento-1.9






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 26 '18 at 15:29









      GerPhysioGerPhysio

      132




      132






















          2 Answers
          2






          active

          oldest

          votes


















          2














          I would do following:




          • create a new temp installation from the backup.

          • Export customers

          • Delete all customers from current site

          • Import from the exported csv file






          share|improve this answer
























          • Will the customers still be able to see the orders on their accounts when they get imported doing it this way?

            – GerPhysio
            Jun 26 '18 at 17:03











          • I'm not convinced they would be able to. But Devtpes' solution is the best one I can think of too.

            – Craig
            Jun 26 '18 at 17:04






          • 1





            No they won't be able to see the orders. In the sales_flat_order table is a column customer_id. After the import, update this column with the new customer-IDs. For mapping, you can use the customer's email address which is present in the customer_entity and the sales_flat_order tables

            – simonthesorcerer
            Jun 26 '18 at 18:29













          • How would I do this for 2000 or so customers? Is there a mysql command I could run to do this?

            – GerPhysio
            Jun 26 '18 at 21:39













          • You can halve your work by only importing the deleted customers. For that you have to export customers from current site and new temp installation then compare both and difference will be imported into current site, after that you can associate newly added customers to the orders. To speed up the work you can use some ready made plugin such as marketplace.magento.com/magebright-magebright-assignorder.html (check the suitability first as I've never used it).

            – Devtype
            Jun 27 '18 at 8:22



















          0














          The deleted customers' orders are still in sales_flat_order only the customer_id is reset to NULL and orders set to archived. That means some of their info is still there.



          Curiously after this accident happened literally during processing an order, Magento created the customer again with a new ID and the order went on like nothing was wrong. Thankfully (for me) I was working on a migration tool so I have a list of customer_ids with email, name, and their original password hash. Working out the steps to manually add them now.





          Edited to add: I have accomplished as much as a repair as I deem practical for now.




          • Got list of customers from the Xfer database whose IDs were up to 1053 (the lowest number remaining in the customer list).

          • Used Mage::getModel() and $customer to add the deleted customer back to Magento 1.

          • Got the new customer id from the newly added customer so I can match to the old customer ID from the Xfer database.

          • Updated customer_entity to fix created_at, the website_id, and store_id.

          • Updated sales_flat_order to set the customer_id where the email matches the one from the Xfer database.

          • Updated sales_flat_invoice to find the previous customer ID and change to the new customer ID.

          • Inserted the password hash from the Xfer database back into customer_entity_varchar.


          Observations:




          • The customers reappear on the manage customers list, only now at the top.

          • Previous sales appear in "purchases".

          • The "orders" tab is blank. Not exactly sure how that tab is populated and not going to pore over the code unless people complain.

          • You'll need to manually make a query to update the website and store IDs. The create customer Mage call I used ignored what I put in.

          • Created_at is broken, but it's not exactly awesome anywhere in our Magento.






          share|improve this answer

























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "479"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f231426%2faccidentally-deleted-customers-magento-1-9%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            I would do following:




            • create a new temp installation from the backup.

            • Export customers

            • Delete all customers from current site

            • Import from the exported csv file






            share|improve this answer
























            • Will the customers still be able to see the orders on their accounts when they get imported doing it this way?

              – GerPhysio
              Jun 26 '18 at 17:03











            • I'm not convinced they would be able to. But Devtpes' solution is the best one I can think of too.

              – Craig
              Jun 26 '18 at 17:04






            • 1





              No they won't be able to see the orders. In the sales_flat_order table is a column customer_id. After the import, update this column with the new customer-IDs. For mapping, you can use the customer's email address which is present in the customer_entity and the sales_flat_order tables

              – simonthesorcerer
              Jun 26 '18 at 18:29













            • How would I do this for 2000 or so customers? Is there a mysql command I could run to do this?

              – GerPhysio
              Jun 26 '18 at 21:39













            • You can halve your work by only importing the deleted customers. For that you have to export customers from current site and new temp installation then compare both and difference will be imported into current site, after that you can associate newly added customers to the orders. To speed up the work you can use some ready made plugin such as marketplace.magento.com/magebright-magebright-assignorder.html (check the suitability first as I've never used it).

              – Devtype
              Jun 27 '18 at 8:22
















            2














            I would do following:




            • create a new temp installation from the backup.

            • Export customers

            • Delete all customers from current site

            • Import from the exported csv file






            share|improve this answer
























            • Will the customers still be able to see the orders on their accounts when they get imported doing it this way?

              – GerPhysio
              Jun 26 '18 at 17:03











            • I'm not convinced they would be able to. But Devtpes' solution is the best one I can think of too.

              – Craig
              Jun 26 '18 at 17:04






            • 1





              No they won't be able to see the orders. In the sales_flat_order table is a column customer_id. After the import, update this column with the new customer-IDs. For mapping, you can use the customer's email address which is present in the customer_entity and the sales_flat_order tables

              – simonthesorcerer
              Jun 26 '18 at 18:29













            • How would I do this for 2000 or so customers? Is there a mysql command I could run to do this?

              – GerPhysio
              Jun 26 '18 at 21:39













            • You can halve your work by only importing the deleted customers. For that you have to export customers from current site and new temp installation then compare both and difference will be imported into current site, after that you can associate newly added customers to the orders. To speed up the work you can use some ready made plugin such as marketplace.magento.com/magebright-magebright-assignorder.html (check the suitability first as I've never used it).

              – Devtype
              Jun 27 '18 at 8:22














            2












            2








            2







            I would do following:




            • create a new temp installation from the backup.

            • Export customers

            • Delete all customers from current site

            • Import from the exported csv file






            share|improve this answer













            I would do following:




            • create a new temp installation from the backup.

            • Export customers

            • Delete all customers from current site

            • Import from the exported csv file







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jun 26 '18 at 16:44









            DevtypeDevtype

            2,09911231




            2,09911231













            • Will the customers still be able to see the orders on their accounts when they get imported doing it this way?

              – GerPhysio
              Jun 26 '18 at 17:03











            • I'm not convinced they would be able to. But Devtpes' solution is the best one I can think of too.

              – Craig
              Jun 26 '18 at 17:04






            • 1





              No they won't be able to see the orders. In the sales_flat_order table is a column customer_id. After the import, update this column with the new customer-IDs. For mapping, you can use the customer's email address which is present in the customer_entity and the sales_flat_order tables

              – simonthesorcerer
              Jun 26 '18 at 18:29













            • How would I do this for 2000 or so customers? Is there a mysql command I could run to do this?

              – GerPhysio
              Jun 26 '18 at 21:39













            • You can halve your work by only importing the deleted customers. For that you have to export customers from current site and new temp installation then compare both and difference will be imported into current site, after that you can associate newly added customers to the orders. To speed up the work you can use some ready made plugin such as marketplace.magento.com/magebright-magebright-assignorder.html (check the suitability first as I've never used it).

              – Devtype
              Jun 27 '18 at 8:22



















            • Will the customers still be able to see the orders on their accounts when they get imported doing it this way?

              – GerPhysio
              Jun 26 '18 at 17:03











            • I'm not convinced they would be able to. But Devtpes' solution is the best one I can think of too.

              – Craig
              Jun 26 '18 at 17:04






            • 1





              No they won't be able to see the orders. In the sales_flat_order table is a column customer_id. After the import, update this column with the new customer-IDs. For mapping, you can use the customer's email address which is present in the customer_entity and the sales_flat_order tables

              – simonthesorcerer
              Jun 26 '18 at 18:29













            • How would I do this for 2000 or so customers? Is there a mysql command I could run to do this?

              – GerPhysio
              Jun 26 '18 at 21:39













            • You can halve your work by only importing the deleted customers. For that you have to export customers from current site and new temp installation then compare both and difference will be imported into current site, after that you can associate newly added customers to the orders. To speed up the work you can use some ready made plugin such as marketplace.magento.com/magebright-magebright-assignorder.html (check the suitability first as I've never used it).

              – Devtype
              Jun 27 '18 at 8:22

















            Will the customers still be able to see the orders on their accounts when they get imported doing it this way?

            – GerPhysio
            Jun 26 '18 at 17:03





            Will the customers still be able to see the orders on their accounts when they get imported doing it this way?

            – GerPhysio
            Jun 26 '18 at 17:03













            I'm not convinced they would be able to. But Devtpes' solution is the best one I can think of too.

            – Craig
            Jun 26 '18 at 17:04





            I'm not convinced they would be able to. But Devtpes' solution is the best one I can think of too.

            – Craig
            Jun 26 '18 at 17:04




            1




            1





            No they won't be able to see the orders. In the sales_flat_order table is a column customer_id. After the import, update this column with the new customer-IDs. For mapping, you can use the customer's email address which is present in the customer_entity and the sales_flat_order tables

            – simonthesorcerer
            Jun 26 '18 at 18:29







            No they won't be able to see the orders. In the sales_flat_order table is a column customer_id. After the import, update this column with the new customer-IDs. For mapping, you can use the customer's email address which is present in the customer_entity and the sales_flat_order tables

            – simonthesorcerer
            Jun 26 '18 at 18:29















            How would I do this for 2000 or so customers? Is there a mysql command I could run to do this?

            – GerPhysio
            Jun 26 '18 at 21:39







            How would I do this for 2000 or so customers? Is there a mysql command I could run to do this?

            – GerPhysio
            Jun 26 '18 at 21:39















            You can halve your work by only importing the deleted customers. For that you have to export customers from current site and new temp installation then compare both and difference will be imported into current site, after that you can associate newly added customers to the orders. To speed up the work you can use some ready made plugin such as marketplace.magento.com/magebright-magebright-assignorder.html (check the suitability first as I've never used it).

            – Devtype
            Jun 27 '18 at 8:22





            You can halve your work by only importing the deleted customers. For that you have to export customers from current site and new temp installation then compare both and difference will be imported into current site, after that you can associate newly added customers to the orders. To speed up the work you can use some ready made plugin such as marketplace.magento.com/magebright-magebright-assignorder.html (check the suitability first as I've never used it).

            – Devtype
            Jun 27 '18 at 8:22













            0














            The deleted customers' orders are still in sales_flat_order only the customer_id is reset to NULL and orders set to archived. That means some of their info is still there.



            Curiously after this accident happened literally during processing an order, Magento created the customer again with a new ID and the order went on like nothing was wrong. Thankfully (for me) I was working on a migration tool so I have a list of customer_ids with email, name, and their original password hash. Working out the steps to manually add them now.





            Edited to add: I have accomplished as much as a repair as I deem practical for now.




            • Got list of customers from the Xfer database whose IDs were up to 1053 (the lowest number remaining in the customer list).

            • Used Mage::getModel() and $customer to add the deleted customer back to Magento 1.

            • Got the new customer id from the newly added customer so I can match to the old customer ID from the Xfer database.

            • Updated customer_entity to fix created_at, the website_id, and store_id.

            • Updated sales_flat_order to set the customer_id where the email matches the one from the Xfer database.

            • Updated sales_flat_invoice to find the previous customer ID and change to the new customer ID.

            • Inserted the password hash from the Xfer database back into customer_entity_varchar.


            Observations:




            • The customers reappear on the manage customers list, only now at the top.

            • Previous sales appear in "purchases".

            • The "orders" tab is blank. Not exactly sure how that tab is populated and not going to pore over the code unless people complain.

            • You'll need to manually make a query to update the website and store IDs. The create customer Mage call I used ignored what I put in.

            • Created_at is broken, but it's not exactly awesome anywhere in our Magento.






            share|improve this answer






























              0














              The deleted customers' orders are still in sales_flat_order only the customer_id is reset to NULL and orders set to archived. That means some of their info is still there.



              Curiously after this accident happened literally during processing an order, Magento created the customer again with a new ID and the order went on like nothing was wrong. Thankfully (for me) I was working on a migration tool so I have a list of customer_ids with email, name, and their original password hash. Working out the steps to manually add them now.





              Edited to add: I have accomplished as much as a repair as I deem practical for now.




              • Got list of customers from the Xfer database whose IDs were up to 1053 (the lowest number remaining in the customer list).

              • Used Mage::getModel() and $customer to add the deleted customer back to Magento 1.

              • Got the new customer id from the newly added customer so I can match to the old customer ID from the Xfer database.

              • Updated customer_entity to fix created_at, the website_id, and store_id.

              • Updated sales_flat_order to set the customer_id where the email matches the one from the Xfer database.

              • Updated sales_flat_invoice to find the previous customer ID and change to the new customer ID.

              • Inserted the password hash from the Xfer database back into customer_entity_varchar.


              Observations:




              • The customers reappear on the manage customers list, only now at the top.

              • Previous sales appear in "purchases".

              • The "orders" tab is blank. Not exactly sure how that tab is populated and not going to pore over the code unless people complain.

              • You'll need to manually make a query to update the website and store IDs. The create customer Mage call I used ignored what I put in.

              • Created_at is broken, but it's not exactly awesome anywhere in our Magento.






              share|improve this answer




























                0












                0








                0







                The deleted customers' orders are still in sales_flat_order only the customer_id is reset to NULL and orders set to archived. That means some of their info is still there.



                Curiously after this accident happened literally during processing an order, Magento created the customer again with a new ID and the order went on like nothing was wrong. Thankfully (for me) I was working on a migration tool so I have a list of customer_ids with email, name, and their original password hash. Working out the steps to manually add them now.





                Edited to add: I have accomplished as much as a repair as I deem practical for now.




                • Got list of customers from the Xfer database whose IDs were up to 1053 (the lowest number remaining in the customer list).

                • Used Mage::getModel() and $customer to add the deleted customer back to Magento 1.

                • Got the new customer id from the newly added customer so I can match to the old customer ID from the Xfer database.

                • Updated customer_entity to fix created_at, the website_id, and store_id.

                • Updated sales_flat_order to set the customer_id where the email matches the one from the Xfer database.

                • Updated sales_flat_invoice to find the previous customer ID and change to the new customer ID.

                • Inserted the password hash from the Xfer database back into customer_entity_varchar.


                Observations:




                • The customers reappear on the manage customers list, only now at the top.

                • Previous sales appear in "purchases".

                • The "orders" tab is blank. Not exactly sure how that tab is populated and not going to pore over the code unless people complain.

                • You'll need to manually make a query to update the website and store IDs. The create customer Mage call I used ignored what I put in.

                • Created_at is broken, but it's not exactly awesome anywhere in our Magento.






                share|improve this answer















                The deleted customers' orders are still in sales_flat_order only the customer_id is reset to NULL and orders set to archived. That means some of their info is still there.



                Curiously after this accident happened literally during processing an order, Magento created the customer again with a new ID and the order went on like nothing was wrong. Thankfully (for me) I was working on a migration tool so I have a list of customer_ids with email, name, and their original password hash. Working out the steps to manually add them now.





                Edited to add: I have accomplished as much as a repair as I deem practical for now.




                • Got list of customers from the Xfer database whose IDs were up to 1053 (the lowest number remaining in the customer list).

                • Used Mage::getModel() and $customer to add the deleted customer back to Magento 1.

                • Got the new customer id from the newly added customer so I can match to the old customer ID from the Xfer database.

                • Updated customer_entity to fix created_at, the website_id, and store_id.

                • Updated sales_flat_order to set the customer_id where the email matches the one from the Xfer database.

                • Updated sales_flat_invoice to find the previous customer ID and change to the new customer ID.

                • Inserted the password hash from the Xfer database back into customer_entity_varchar.


                Observations:




                • The customers reappear on the manage customers list, only now at the top.

                • Previous sales appear in "purchases".

                • The "orders" tab is blank. Not exactly sure how that tab is populated and not going to pore over the code unless people complain.

                • You'll need to manually make a query to update the website and store IDs. The create customer Mage call I used ignored what I put in.

                • Created_at is broken, but it's not exactly awesome anywhere in our Magento.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 29 mins ago

























                answered 4 hours ago









                Chris KChris K

                249313




                249313






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f231426%2faccidentally-deleted-customers-magento-1-9%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Magento 2 controller redirect on button click in phtml file

                    Polycentropodidae