cancel
Showing results for 
Search instead for 
Did you mean: 

Generate random sales order number

SOLVED

Generate random sales order number

How can I generate random sales order numbers.  Thanks in advance for your attention.

7 REPLIES

Re: Generate random sales order number

Hi @shebafoods,

 

Maybe you should explore what happens here:

 

\Magento\Sales\Model\Increment::getNextValue

And then here too:

 

\Magento\Eav\Model\Entity\Type::fetchNewIncrementId

As you can see the second method is looking for the next value.

I guess you can try a plugin over the Magento\Sales\Model\Order class to change the beforeSave method and change the incrementId.

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"

Re: Generate random sales order number

Many thanks Damian. Which file are the syntax in?

Re: Generate random sales order number

Hi @shebafoods,


You'll find, for example, at:

 

/vendor/magento/eav/model/entity/type.php
--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"

Re: Generate random sales order number

I am using 2.2.1. There is no directory ==> /vendor/magento/eav/model/
entity and no type.php

Re: Generate random sales order number

Maybe you've installed from github?

 

https://github.com/magento/magento2/blob/2.1.7/app/code/Magento/Eav/Model/Entity/Type.php

 

 

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"

Re: Generate random sales order number Type.php

Thanks for your responses. I am using 2.2.1 There is no Type.php in
2.2.1 and no directory ==> /app/code/Magento/Eav/Model/Entity/

Please check. Thanks again.

Re: Generate random sales order number Type.php

I found the Type.php in /vendor/magento/module-eav/Model/Entity/ 

BUT made the changes in vendor/magento/module-sales-sequence/Model/Sequence.php

After playing with a number of formulas, I settled on this one.

 return $this->getCurrentValue()*RAND(1,1000000);

 

If anyone has other suggestions, I'll love to hear it.