How can I generate random sales order numbers. Thanks in advance for your attention.
Solved! Go to Solution.
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.
Hi @Sheba,
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.
I am using 2.2.1. There is no directory ==> /vendor/magento/eav/model/
entity and no type.php
Maybe you've installed from github?
https://github.com/magento/magento2/blob/2.1.7/app/code/Magento/Eav/Model/Entity/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.
Isn't there a chance for not generating unique order numbers?