I am trying to remove the leading zeros from the order numbers. I have figured out how to set the sequence just fine. We want to set the orders to start in the 275000 range.

Right now its in the database, visually, etc at 0000275000.

I'd like it to show just 275000.

Any guidance is appreciated. I thought this could be solved via database, but I am not seeing it.

  • Just a guess: is ZEROFILL enabled for the column?
    – pong
    Commented Nov 7, 2016 at 20:47
  • You can modified Incrment id from eav_entity_store table.
    – Kul
    Commented Nov 7, 2016 at 20:52
  • pong, no it is not. Kul, I have changed that to a higher number, but it never has incremented. Maybe I'm not understanding it? It doesn't seem to be picked up anywhere. I have the value set at 1001250.
    – Dan Joseph
    Commented Nov 7, 2016 at 21:10
  • @pong : how to enable ZEROFILL for a column while install or upgrade schema
    – Ashish Raj
    Commented Oct 11, 2018 at 8:40

3 Answers 3


This article helped me with this issue: https://www.classyllama.com/blog/m2-incrementid

What I did on my site is create a module (or you can piggy-back on an existing module) and this is my etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Framework\DB\Sequence\SequenceInterface">
            <argument name="pattern" xsi:type="string">%s%'.06d%s</argument>

In case of string you can use

$str ="000123"; echo $fixed_str = preg_replace('/000+/','',$str);

output will be 123.

In case of int you can just convert the int to string and then try this method


Connect to your database and execute below queries.

ALTER TABLE  `sequence_order_1` AUTO_INCREMENT = 275000;
ALTER TABLE  `sequence_invoice_1` AUTO_INCREMENT = 275000;
ALTER TABLE  `sequence_shipment_1` AUTO_INCREMENT = 275000;
ALTER TABLE  `sequence_creditmemo_1` AUTO_INCREMENT = 275000;

Please Note: 1) Please take backup your database before executing this commands.

2) Import point is Please try in your local instance and verify the same from end to end then proceed further.

3) The changes will effect for the upcoming order.

Please let me know if you facing any issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.