My client wants the current month and year as a prefix in order numbers. I have read many blogs but they are all for static prefix for order number.
I am looking for a solution in Magento 2.
increment-idmagento-2.0.7magento2orders
My client wants the current month and year as a prefix in order numbers. I have read many blogs but they are all for static prefix for order number.
I am looking for a solution in Magento 2.
Best Answer
You can do that with a custom increment model.
You can read about increment models here: How to set order increment id iterator in magento 1?
In Magento 2, the implementation is still the same. In your case, you would extend
Magento\Eav\Model\Entity\Increment\NumericValue
and add agetPrefix()
method to implement your custom prefix:Then update
increment_model
for orders in theeav_entity_type
table and change it fromMagento\Eav\Model\Entity\Increment\NumericValue
to your model (e.g.Stack\OrderNumber\Model\Entity\Increment\DatePrefix
)