change order id prestashop

Change the order id of orders using MYSQL on Prestashop 1.5

When we are migrating a installation that is in production, it is possible that the new installation has got a old version of database and that several orders are missing. The reason of this is because we are working with a dump catched in the time X but the shop in production is still working, thus the shop is still receiving new orders and new customers that there are not in our production database (the copy of time X).

When we have finished the work and the new version is ready to be installed in the production server with the old database, we need at least to indicate that the new orders will begin from the last id of the production database. In this case, we need to execute this query to move the next id:

1
ALTER TABLE ps_orders AUTO_INCREMENT = :last_id + 1

Perphaps you are reading this article because you have recieved new orders in the production servers using the last order id of the old database, in this case, you need yo move the orders id generated to the real last id. Here are the queries to do that, only replace :old_id and :new_id.

1
2
3
4
5
6
7
8
9
UPDATE ps_order_carrier SET id_order = :new_id WHERE id_order = :old_id;
UPDATE ps_order_cart_rule SET id_order = :new_id WHERE id_order = :old_id;
UPDATE ps_order_detail SET id_order = :new_id WHERE id_order = :old_id;
UPDATE ps_order_history SET id_order = :new_id WHERE id_order = :old_id;
UPDATE ps_order_invoice SET id_order = :new_id WHERE id_order = :old_id;
UPDATE ps_order_invoice_payment SET id_order = :new_id WHERE id_order = :old_id;
UPDATE ps_order_return SET id_order = :new_id WHERE id_order = :old_id;
UPDATE ps_order_slip SET id_order = :new_id WHERE id_order = :old_id;
UPDATE ps_orders SET id_order = :new_id WHERE id_order = :old_id

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>