I need to increment each new invoice id by 5, i have tried below code.

But changed all invoices, shipments, orders and credit memos.

I need each new invoice id increment by 5, shipments increment by 5 and credit memos increment by 3.

Also sales order increment by 1(normal).

How can i do this .?

Any one help me.

class Mage_Eav_Model_Entity_Increment_Numeric extends Mage_Eav_Model_Entity_Increment_Abstract    
   public function getNextId()
        $last = $this->getLastId();

        if (strpos($last, $this->getPrefix()) === 0) {
            $last = (int)substr($last, strlen($this->getPrefix()));
        } else {
            $last = (int)$last;

        $next = $last + 5;

        return $this->format($next);

2 Answers 2


You can write the triggers for ID or you can write procedure to change the autoincrement id to set to +5 each time whenever a record is inserted. Make sure to alter parent-child relationships.


You can set different increment models for each document type in the database. Now they use the same class, so the changes affects all types.

Alternatively, you can check the entity type inside this method and apply custom number increment logic.

As a third option, you can search magento connect for custom order number extension.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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