Magento 1.5中订单号的自定义起始编号

Magento 1.5中订单号的自定义起始编号,magento,configuration,e-commerce,magento-1.5,Magento,Configuration,E Commerce,Magento 1.5,如何在Magento 1.5中自定义订单、发票等的起始编号? 来自magento论坛: ,更改起始编号(通过sql查询): ,更改起始编号(通过db管理工具)并删除起始处的“0”: 希望对Magento订单号有所帮助 很简单 转到phpmyadmin 选择数据库,然后选择表“eav\u实体\u存储” 在此表中,更改增量\u last\u id(例如,我在表中设置了3456767) 之后,我创建了一个新订单。现在我的订单是从346768号开始的 事实上,对于较新的版本(可能还有1.5版)

如何在Magento 1.5中自定义订单、发票等的起始编号?


来自magento论坛:

  • ,更改起始编号(通过sql查询):
  • ,更改起始编号(通过db管理工具)并删除起始处的“0”:

希望对Magento订单号有所帮助 很简单

  • 转到phpmyadmin
  • 选择数据库,然后选择表“eav\u实体\u存储”
  • 在此表中,更改增量\u last\u id(例如,我在表中设置了3456767)
  • 之后,我创建了一个新订单。现在我的订单是从346768号开始的

事实上,对于较新的版本(可能还有1.5版),有一种更简单的方法来更改它。在PHPMyAdmin或mysql客户端中,转到
eav\u entity\u type
表。在
entity\u type\u code
列(可能是
order
)中找到该表,并将
increment\u pad\u length
以及
increment\u pad\u char设置为所需的长度

这样你就不必重写核心代码了,这是一个双赢的局面

JMax

完成这项任务实际上有一个很好的方法

它允许您以多种不同的方式自定义订单ID: 例如,您可以使用以下各项的组合:

  • 年、月、日、时、秒等数字
  • 使用自定义计数器(您可以决定起始编号)
  • 所有上述方法的组合
  • 在订单ID的任何位置添加一些自定义字符串
  • 这是Magento connect上的分机:


    我亲自试用过,效果非常好(适用于我所有的付款方式,我一点问题也没有)

    这有一个易于使用的扩展:我试用过,对订单号很有效,但订单id不同。例如,当我下订单并单击订单详细信息时,url为:sales/order/view/order\u id/7/ There is a table in the database which stored increment id of order. It is called “eav_entity_store” table. You can check which entity type id belongs to which entity by looking at eav_entity_type table. You can run following query to update last increment id for the order.
    
        update eav_entity_store
        inner join eav_entity_type on eav_entity_type.entity_type_id = eav_entity_store.entity_type_id
        set eav_entity_store.increment_last_id=3001 
        where eav_entity_type.entity_type_code='order';
    With a tool like phpmyadmin look at your database. In the table eav_entity_type you will find all entity types listed. The one of interest to change where the order number starts is order sales/order. Remember the entity_type_id (in my install it is 11). To remove the leading zeros (padding) set increment_pad_length to 1.

    Next go to the table eav_entity_store. Look up the entity_type_id. Now you can change the value of increment_prefix and increment_last_id. If you wanted to have your next orderId to be 15000 set increment_last_id to 14999 and increment_prefix to 0.

    Additionally you need to make a copy of this file /app/code/core/Mage/Eav/Model/Entity/Increment/Abstract.php to /app/code/local/Mage/Eav/Model/Entity/Increment/Abstract.php
        public function getPadLength()
        {
            $padLength = $this->getData('pad_length');
            if (empty($padLength)) {
               $padLength = 0;
            }
            return $padLength;
        }
        ...
        public function format($id)
        {
            $result= str_pad((string)$id, $this->getPadLength(), $this->getPadChar(), STR_PAD_LEFT);
            return $result;
        }