Can I change the starting order number?

Can I change the starting order number?

August 12, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Can I change the starting order number?

Changing Magento Sales Order IDs: A Step-by-Step Guide

As a seasoned developer who’s worked extensively with e-commerce platforms, I often receive requests to customize order numbering in Magento. By default, Magento assigns incremental IDs starting from #100000001 for sales orders. But what if you want to change the initial number or reset the count? Let me walk you through a practical solution.

Understanding the Default Behavior

Before diving into the code, let’s understand how Magento manages order IDs. The increment_id field in the sales_flat_order table is responsible for generating unique order numbers. By default, it uses the following configuration:

  • Prefix: Empty
  • Suffix: Empty
  • Length: 8 digits
  • Initial Value: 1

Changing the Starting Order ID

To change the starting order number to #200000003, you’ll need to edit the core_resource table and update the increment_id field configuration. Here’s how:

UPDATE core_resource
SET data = 'a:4:{s:16:"increment_prefix";N;s:8:"increment_suffix";N;'
    || 's:3:"length";i:8;'
    || 's:7:"last_id";s:9:"200000002";'
    || 's:5:"seq_num";i:1}'
WHERE code = 'sales_sequence';

This SQL query updates the data column of the core_resource table for the sales_sequence resource. It sets the following:

  • increment_prefix: Empty string (N)
  • increment_suffix: Empty string (N)
  • length: 8 digits
  • last_id: Set to #200000002 (Remember, we want #200000003 as our first order)
  • seq_num: Starting sequence number set to 1

Resetting the Sequence Counter

If you’ve reached a high order count and want to reset it without changing the starting value, you can update the last_id field directly:

UPDATE core_resource
SET data = 'a:4:{s:16:"increment_prefix";N;s:8:"increment_suffix";N;'
    || 's:3:"length";i:8;'
    || 's:7:"last_id";s:9:"0";'
    || 's:5:"seq_num";i:1}'
WHERE code = 'sales_sequence';

This query resets the last_id to 0, effectively starting with #1 again while keeping your existing order numbering scheme intact.

Best Practices and Limitations

While these queries provide a quick solution, there are some important considerations:

  • Always backup your database before making changes.
  • Ensure you understand the implications of changing order IDs. It affects your internal system tracking and may impact third-party integrations.
  • Magento 2 introduces more complex sequencing with multiple resources for different entities. The above example applies to sales orders only.

If you’re looking for a more robust solution that handles multiple entity types, I recommend exploring the official Magento documentation on increment IDs configuration.

Conclusion

Changing the starting order ID in Magento is straightforward once you understand the underlying database structure. By updating the core_resource table, you can customize your order numbering scheme to meet your business needs.

Remember, any modifications to core tables should be done with caution and proper version control. If you’re unsure about the technical implications or need further assistance, don’t hesitate to reach out to our team at Laravel Company.

Stay tuned for more Magento tutorials and best practices!

Database Configuration Orders Errors

Our network