4

Is there possible for magento 1 to increase order id each time plus 4.

Ex.

My current order is 10001 and when we placed next time order from store next id would be 10005, after another next time it would be 10009.

Each time order increment id will be +4 from current order id.

2

Yes, if you implement your own increment model

From my blog post on increment models:

Writing Custom Increment Models

You can specify any class as increment model that implements Mage_Eav_Model_Entity_Increment_Interface. Be aware: This interface pretents to only need one method, getNextId(), but at least the following setters will be called as well:

  • setPrefix
  • setPadLength
  • setPadChar
  • setLastId
  • setEntityTypeId
  • setStoreId

Yeah, Magento doesn’t give much love to interfaces. So if you want to implement your own increment model, you should at least inherit from Varien_Object, better from Mage_Eav_Model_Entity_Increment_Abstract which already provides you with the prefix and padding logic.

In the method getNextId() you will then generate the next increment id based on the last one, that is accessible with $this->getLastId()

So in your case this would be:

class Stack_Model_Entity_IncrementStep extends Mage_Eav_Model_Entity_Increment_Abstract
{
    const STEP = 4;
    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 + self::STEP;
        return $this->format($next);
    }
}

This is mostly copied from Mage_Eav_Model_Entity_Increment_Numeric where it is +1 instead of + self::STEP. You probably want to replace the constant in this minimum example with a configuration value.

Then update increment_model for orders in the eav_entity_type table and change it from eav/entity_increment_numeric to your model (e.g. stack/entity_incrementStep)

  • :facepalm: obviously that was so easy ^^ lol totally missed the fact that the class is stored in the DB too. – Raphael at Digital Pianism Aug 31 '16 at 10:34
1

The problem here is that Magento does not use the MySQL autoincrement for the increment id.

The increment ids are stored in the eav_entity_store and incremented by a class.

For numeric increment, the class is Mage_Eav_Model_Entity_Increment_Numeric and the method that takes care of the increment is getNextId :

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+1;

    return $this->format($next);
}

I could suggest that you rewrite that class to replace this line:

$next = $last+1;

With:

$next = $last+4;

However, that will also affect the invoices, shipments and credit memos increment ids.

  • i want to do only for order, without invoice,shipments and credit memos, Is there possible for that? – Rakesh Jesadiya Aug 31 '16 at 10:22
  • @Rakesh it's definitely possible but requires way more work and I'm not too sure how to work it out – Raphael at Digital Pianism Aug 31 '16 at 10:24
  • 2
    Not so much work, if you know how ;) See my answer – Fabian Schmengler Aug 31 '16 at 10:32
0

Magento set a order increment id from Mage_Sales_Model_Order at function _beforeSave().

If you would chnage at here then your problem will resolved

  • plz let me know for what to do inside _beforeSave() method? – Rakesh Jesadiya Aug 31 '16 at 10:32

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.