Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

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);
    }
}
share|improve this question
    
I am interested to know, why you need this behaviour ? –  programmer_rkt Aug 1 at 6:29
    
@programmer_rkt learning Magento core functionality...! My TL gives sample task. –  Vijay S Aug 1 at 6:36
    
@VijayS I find that atwix.com/magento/custom-order-and-customer-numbers is a good blog post about making a custom increment model –  David Manners Aug 1 at 6:59

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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