The error occurs if there are orders in the Magento 1 database with no increment_id
set. You can check if you have such orders by running the following SQL statement in your Magento 1 database:
select count(*) from sales_flat_order where increment_id = '' OR increment_id is NULL;
If the returned value is greater than 0, you should update the tables sales_flat_order
and sales_flat_order_grid
in such a way to ensure that all your orders have increment_ids and those are unique.
If you find incrment_ids
in the sales_flat_order_grid
table for all orders, just take the values from there with the following statemen:
update sales_flat_order o
join sales_flat_order_grid g
on o.entity_id = g.entity_id
set o.increment_id = g.increment_id
where o.increment_id = '' OR o.increment_id is NULL;
If you don't find orders without any increment_id it might be the best option to create arbitrary increment_ids. For example you can use a SQL update statement which builds an increment_id
based on the entity_id
and a prefix of your choice (just replace the prefix in the sample statements with something which doesn't conflict with existing increment_ids):
update sales_flat_order set increment_id = concat ('990000', entity_id) where increment_id is null;
update sales_flat_order_grid set increment_id = concat ('990000', entity_id) where increment_id is null;
Best Answer
To fix this issue, you need to change your
increment_last_id
of yourinvoice
entity type.By default in magento invoice entity type is 6. Which you can find in
eav_entity_type
table.You need to change
increment_last_id
value for your store. Theincrement_last_id
is ineav_entity_store
table. You can run following query to update your invoiceincrement_last_id
. Where X is your newincrement_last_id
and STORE_ID_HERE is your store id to whom you changing invoiceincrement_last_id
.OR
Notice that the value for increment_last_id already contains the increment_prefix. Use your entity_type increment_prefix
For more details check here : https://www.warpconduit.net/2012/04/18/how-to-change-the-order-increment-id-and-prefix-in-magento/
Hope it helps.