Magento 2 how to change order increment id?
-
06-03-2021 - |
문제
I just migrate data from magento 1 to magento 2
Magento 1 order id start with 10000001
and magento 2 order id start with 00000001
So we need order id start from 100000062
in magento 2 (because in magento 1 last order id is 100000061)
i checked a stackexchange but they all start from they only suggest change default order id.
다른 팁
You have access to the database and can run MySQL queries, You can use update the increment id via SQL:
-- Edit Store-Id & New Order Increment Id
SET @STORE_ID = 2;
SET @NEW_INC_ID = 100000062;
-- Do not edit below
SET @ENTITY_TYPE_ID := (SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code = 'order');
-- Just for checking
SET @LAST_INC_ID := (SELECT increment_last_id FROM eav_entity_store WHERE entity_type_id = @ENTITY_TYPE_ID AND store_id = @STORE_ID AND increment_prefix = @STORE_ID);
-- Update first eav_entity_store table
UPDATE eav_entity_store SET increment_last_id = @NEW_INC_ID WHERE entity_type_id = @ENTITY_TYPE_ID AND store_id = @STORE_ID AND increment_prefix = @STORE_ID;
-- Update sequence_order_{store-id} table
SET @ORDER_SEQUENCE_TABLE := CONTACT('sequence_order_', @STORE_ID);
SET @SQL := CONCAT('ALTER TABLE ', @ORDER_SEQUENCE_TABLE, ' AUTO_INCREMENT = ', @NEW_INC_ID);
PREPARE STMT FROM @SQL;
EXECUTE STMT;
제휴하지 않습니다 magento.stackexchange