I try to short order number from 11 to 6.

In database I select table eav_entity_type

SELECT * FROM `eav_entity_type`

go to table "order" and looking for increment_pad_length

enter image description here

I found that I have to change the record increment_pad_lenght

But here I have value 8 (in magento order ID have 11 digitals).

I change this value to 4 and update magento

php bin/magento setup:upgrade

unfortunately I did not receive any result. Any one know how to do?

EDIT: after database query

select * from sales_sequence_meta;

I see table sequence_order_1, sequence_order_2, sequence_order_3 etc. enter image description here

After edit for example sequence_order_1 I cannot see AUTO_INCREMENT record.

EDIT: After:

mysql: select * from sales_sequence_meta;

ALTER TABLE sequence_order_0 AUTO_INCREMENT=7895;
ALTER TABLE sequence_order_1 AUTO_INCREMENT=7895;
ALTER TABLE sequence_order_2 AUTO_INCREMENT=7895;
ALTER TABLE sequence_order_3 AUTO_INCREMENT=7895;
ALTER TABLE sequence_order_4 AUTO_INCREMENT=7895;
ALTER TABLE sequence_order_5 AUTO_INCREMENT=7895;
ALTER TABLE sequence_order_6 AUTO_INCREMENT=7895;

my order ID is still the same.

@Rakesh Varma, In file /vendor/magento/module-sales-sequence/Model/Sequence.php, on line 19 I have:

const DEFAULT_PATTERN  = "%s%'.09d%s";

When I edit file: app/etc/di.xml and adding below line:

<?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>

Get error:

Fatal error: Uncaught Magento\Framework\Exception\LocalizedException: Invalid XML in file /home/brandswearxv/ftp/app/etc/di.xml: XML declaration allowed only at the start of the document Line: 1233 Extra content at the end of the document Line: 1234 in /home/brandswearxv/ftp/vendor/magento/framework/Config/Reader/Filesystem.php:151 Stack trace: #0 /home/brandswearxv/ftp/vendor/magento/framework/Config/Reader/Filesystem.php(127): Magento\Framework\Config\Reader\Filesystem->_readFiles(Object(Magento\Framework\Config\FileIterator)) #1 /home/brandswearxv/ftp/vendor/magento/framework/App/ObjectManagerFactory.php(282): Magento\Framework\Config\Reader\Filesystem->read('primary') #2 /home/brandswearxv/ftp/vendor/magento/framework/App/ObjectManagerFactory.php(142): Magento\Framework\App\ObjectManagerFactory->_loadPrimaryConfig(Object(Magento\Framework\App\Filesystem\DirectoryList), Object(Magento\Framework\Filesystem\DriverPool), Object(Magento\Framework\ObjectManager\Config\Mapper\Dom), 'developer') #3 /home/brandswearxv/ftp/ve in /home/brandswearxv/ftp/vendor/magento/framework/App/ObjectManagerFactory.php on line 284
  • Do you want to change order increment_id length? for example 00000001 to 001?
    – Keyur Shah
    Feb 4, 2018 at 11:13
  • Yes, I have to change the length of the order numbers because I have an integrated magento with the sales system and this system does not accept such a long order number. Do you know how to do ?
    – Sylvester
    Feb 4, 2018 at 12:07
  • Check this magento.stackexchange.com/questions/101341/…
    – Keyur Shah
    Feb 4, 2018 at 12:17
  • @KeyurShah Thanks, but I cannot see one thing (I have updated my post).
    – Sylvester
    Feb 4, 2018 at 12:40
  • Did you place any new order? to see the effect you need to place a new order and one more thing don't set the same number(as I can see that you set the 7895 for all store ) for all store otherwise it will break
    – Keyur Shah
    Feb 4, 2018 at 12:52

2 Answers 2


To change the padding for the order number you have to override default constant 


 which is set in: /vendor/magento/module-sales-sequence/Model/Sequence.php, on line 19. We can change this in a custom module by creating 


 with the following content:

<type name="Magento\Framework\DB\Sequence\SequenceInterface">
        <argument name="pattern" xsi:type="string">%s%'.06d%s</argument>

You can read more details from here... https://www.classyllama.com/blog/m2-incrementid

  • Thanks Rakesh, I update my topic, can you check? Thanks.
    – Sylvester
    Feb 4, 2018 at 15:53
  • You have to add di.xml file in under your module... Feb 4, 2018 at 15:55
  • ahh and that would solve this problem! Only to which folder should I upload the new creating file di.xml ? What do you mean "under your module". Thanks
    – Sylvester
    Feb 4, 2018 at 15:58
  • 1
    You have to create your own module and create di.xml file you can use this website to create module... mage2gen.com Feb 4, 2018 at 16:01
  • You welcome.. let me know if you face other issue. Feb 4, 2018 at 16:03

You can also try this in magento 2.3+ this will work.

Create di.xml in your module

[namespace] / [modulename] /etc/di.xml

And paste This code

<?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\SalesSequence\Model\Sequence">
        <argument name="pattern" xsi:type="string"><![CDATA[%s%'.06d%s]]></argument>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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