4

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.

  • have you done this? – Bojjaiah Dec 1 '16 at 9:08
  • @magentotwo No I am Not able to do this, do You have solution or you want solution for this ? – Murtuza Zabuawala Dec 1 '16 at 9:11
  • I want solution for this? – Bojjaiah Dec 1 '16 at 9:15
  • @magentotwo Sorry brother I am not able to find solution for this – Murtuza Zabuawala Dec 1 '16 at 9:16
  • @magentotwo You can ask new question and put this question link as reference may be someone help you out – Murtuza Zabuawala Dec 1 '16 at 9:20
4

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 a getPrefix() method to implement your custom prefix:

namespace Stack\OrderNumber\Model\Entity\Increment;

use Magento\Eav\Model\Entity\Increment\NumericValue;
class DatePrefix extends NumericValue
{
    public function getPrefix()
    {
        return \date('m-y');
    }
}

Then update increment_model for orders in the eav_entity_type table and change it from Magento\Eav\Model\Entity\Increment\NumericValue to your model (e.g. Stack\OrderNumber\Model\Entity\Increment\DatePrefix)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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