Magento 2 is using the class
Magento\SalesSequence\Model\Sequence to generate a reserved order number prior to actually placing an order. I would like to override this class to create custom increment numbers but the fact that the variables are private prevents the subclass from accessing them.
As suggested on Mage2.pro, having the properties declared as protected instead would be simpler.
Not Conceivable Solutions
Editing Core Files
I'm able to achieve my goal by directly editing the core file
Magento\SalesSequence\Model\Sequence – which is of course not the solution I'm looking for.
I'm aware that it is possible to use observer to set the order number later in the process but I imperatively need the order number to be set when initially reserved as other extensions will be relying on it.
Using an after plugin on the
getCurrentValue() function, I am able to retrieve the system generated number and entirely control the returned number. This would work perfectly if I would be able to access the
meta variable to identify for which
entity_type the function is currently executed. Still, this variable is private and therefore inaccessible.
At the time of writing, I was not able to find any useful information online related to this new method used by Magento 2 for assigning order numbers. Everything seems to be build so that Prefixes, Suffixes and even the pattern can be changed easily but nothing is integrated within the Community Edition admin interface.
I'm looking for a solution which will allow to add dynamic information to the resulting order number, not simply static Prefixes or Suffixes added through the
sales_sequence_profile database table.
Different Entity Types
Sequence class is used for generating different numbers for different
shipment based on the data stored in the
sales_sequence_meta database table. This means that the method responsible for dynamically creating new numbers must have access to this sequence meta to identify for which entity type it is currently creating a number allowing it to be adapted in consequence.
Indications from someone who was able to achieve this goal would be very appreciated!
Any suggestion is welcomed!