Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Custom order number, or at least custom starting number
 
John R
Sr. Member
 
Total Posts:  90
Joined:  2008-08-21
 
scree - 26 August 2008 12:20 AM

I did it. Consecutive order numbers AND invoice numbers.

The trick:

In eav_entity_store I added two entries:

for orders:

entity_type11
store_id
0
increment_prefix
0
increment_last_id
000080000 (to start with)

for invoices:
entity_type16
store_id
0
increment_prefix
0
increment_last_id
000010000 (to start with)

additionally I changed the values of “increment_per_store” from 1 to 0 for entity_type_code 11 and 16 (order and invoice) in eav_entity_type.

hth,
j.

It appears to be working in 1.1.6 ..... however I am always super skeptical of these kinds of changes when updates come down the road. Some insight from the Magento team would be crucial before I put this into production

EDIT: However .. say you create two orders (80000001 and 80000002), and then invoice 80000002 first ... the invoice becomes 80000001. So order and invoice numbers are not synced with this solution - if that is in fact what you were going for......

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

80000001 and 80000002 are just alias for orders/invoices. We tried to split it up a little, so our orders start from 80000, invoices from 10000 and shipments from 50000. smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

The problem I have now:
I have a Website including three stores (two store views each) having the same invoicing circuit. Now I need another website with two stores, but with another circuit. Anbody got an idea?

 
Magento Community Magento Community
Magento Community
Magento Community
 
tjscgroup
Sr. Member
 
Avatar
Total Posts:  146
Joined:  2008-09-24
United Kingdom
 

Please ignore this post if it is totally off topic…

I would like to be able to run different numbering sequences for some/each store.  For example:
Store One = ABC05461, ABC05462 etc
Store Two = FGH00212, FGH00213 etc
Store Three & Store Four = PLM43566, PLM43567 etc

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

tjscgroup, I need the same thing now. Could you find a solution to this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

"increment_per_store” would be a good solution (if somebody of the Magento Team ever reads this).

 
Magento Community Magento Community
Magento Community
Magento Community
 
lisali
Enthusiast
 
Avatar
Total Posts:  889
Joined:  2008-04-28
London, UK
 

This should be editable in the admin, definitely.

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

But where? I think, you can only have consecutive numbering for “store views” (e.g. English store or German store), but not for “websites” or “stores”. Could somebody confirm this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
John R
Sr. Member
 
Total Posts:  90
Joined:  2008-08-21
 

I’ve tested this to high heaven in a dev environment and it looks like it’s working ...

If you want to change the # for Shipments and Credit Memos - change numbers 19 and 23 respectively.

I am putting this in a production environment. Let’s hope I don’t regret this down the road!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

I coded an extension for Numeric.php and “hacked” the invoice thing. Now I have an extra invoice numbering for two store views. But the code is too ugly to post it here. wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
ASchroder
Member
 
Avatar
Total Posts:  49
Joined:  2008-10-09
New Zealand
 

FYI to those who have been setting the padLength to 0 and still ben getting 8. The problem is the test being used is PHP’s empty() function which resolves 0 to false.(See: http://php.net/empty)

From: app/code/core/Mage/Eav/Model/Entity/Increment/Abstract.php around line 37.

$padLength $this->getData('pad_length');
        if (empty(
$padLength))  {
            $padLength 
8;
        
}

Not being a PHP programmer I’m not sure what the best practice is here, surely the empty is meant as a kind of != null check but when applied to integers has the annoying side effect that it treats 0 and empty.

The workaround suggested earlier (change the 8 to 0) will work, but will mean if you really do have an undefined padLength, it will default to 0.

I’m using that for now, but if a PHP guru cares to suggest a more appropriate test, I’ll change it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
matponta
Member
 
Total Posts:  39
Joined:  2008-05-20
Italy
 

Hi.

I tried to change to order and invoice numbers from a per store to a unique seguential numbering scheme, but even with the increment_per_store set to 0 for both values orders are still created with the old prefixes… disregarding the eav_entity_store values set with Store id=0.

If you have this problem flushing the cache will fix it, as even part of the eav tables are cached.

Just thought it was worth mentioning
Mattia

 
Magento Community Magento Community
Magento Community
Magento Community
 
Magentourist
Member
 
Total Posts:  48
Joined:  2008-08-11
Berlin
 

I used scree’s approach and created a new module. I used the same directory structure and the module is listed in the backend. Hower neither the invoice nor the billing number is changed. I added a simple return ‘test’; into the getNextId()
method but there’s no output.

How can I get this to work?

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

Could you show us your XML file and class file?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Magentourist
Member
 
Total Posts:  48
Joined:  2008-08-11
Berlin
 

The config.xml

[/code]
<?xml version
="1.0"?>
<config>
    <
modules>
        <
MyModule_ConsecutiveNumbering>   
            <
version>0.1.0</version>
        </
MyModule_ConsecutiveNumbering>
    </
modules>
    <global>       
        <
models>
            <
consecutivenumbering>
                <class>
MyModule_ConsecutiveNumbering_Model</class>               
            </
consecutivenumbering>
            <
eav>
                <
rewrite>
                    <
entity_increment>MyModule_ConsecutiveNumbering_Model_Entity_Increment_Numeric</entity_increment>
                </
rewrite>
            </
eav
        </
models>       
    </global>   
</
config>
The class file conscutiveNumbering.php:
<?php
class MyModule_ConsecutiveNumbering_Model_ConsecutiveNumbering extends Mage_Core_Model_Abstract
   
      {
   
        
   
      }
Numeric.php:
<?php

class MyModule_ConsecutiveNumbering_Model_Entity_Increment_Numeric extends Mage_Eav_Model_Entity_Increment_Numeric
{
    
public function getNextId()
    
{        
    
return "test";

    
}
}
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top