2011-04-29 109 views

回答

10


從Magento的論壇:

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; }

希望幫助

+0

它當然可以,謝謝 – 2011-05-02 02:24:10

3

Magento的訂單號
很簡單....

  • 去phpmyadmin的
  • 選擇datbase,然後選擇表「eav_entity_store 「
  • 在此表中,更改increment_last_id(例如,我在表格中設置了3456767)
  • 之後我創建了一個新訂單。現在我的訂單從數字開始346768
+0

我試過了,它對於訂單號碼的效果很好,但是訂單號是不同的。例如,當我下訂單並點擊訂單詳情時,網址爲:sales/order/view/order_id/7 / – NotJay 2015-08-21 20:13:40

2

實際上,對於較新的版本(也可能在1.5版本中),有一種更簡單的方法來更改它。在PHPMyAdmin或您的mysql客戶端中,轉至eav_entity_type表。找到entity_type_code列中的表格(可能爲order),並將increment_pad_length設置爲任何你想要的,以及increment_pad_char

那麼你不必重寫核心代碼 - 一個雙贏。

JMAX

0

有實際上是爲完成這一任務good extension

它允許您自定義的順序ID在很多不同的方式: 例如,你可以使用一個組合:

  1. 像數年,月,,日,小時,秒,
  2. 使用自定義計數器(你可以決定起始編號)
  3. 的所有上述方法進行組合
  4. 添加一些自定義字符串中的順序編號的任何位置

這是分機。在Magento的連接: http://www.magentocommerce.com/magento-connect/custom-order-id-8210.html

我親自試過它,它很好的(正常工作與我所有的支付方式和我沒有任何問題,在所有)