2012-11-28 75 views
3

我需要修改我的默認發票號碼從1000000012012 - 00001Magento - 自定義發票號碼

我知道我在哪裏可以找到increment_last_id在表eav_entity_store。但我不知道我必須設置哪種格式的發票號碼。

請幫助一些建議。

回答

1

您可以通過編輯下面的類定製訂單/發票/貸記通知單/出貨數(increment_id):

Mage_Eav_Model_Entity_Increment_Numeric 

特別是密切關注以下方法的代碼:

getNextId()getPrefix()getPadLength()format($id)

現在,您不會找到getPrefix(),getPadLength()方法的方法定義,因爲這些方法都是神奇的getter方法。你可以根據你的意願定義這些方法。

舉一個例子:

public function getPrefix(){ 

    $prefix = $this->_getData('prefix'); 

    /* Do some customization */ 

    return $prefix; 
} 
public function getPadLength() 
{ 
    $padLength = $this->_getData('pad_length'); 

    /* Do some customization */ 

    return $padLength; 
} 

這樣,您就不必在數據庫結構手動改變任何東西此實現。

希望這會幫助你。

0

更改發票編號的最好辦法是下面這個簡單的SQL查詢來運行:

  1. 檢查發票紀錄eav_entity_store表通過運行下面的查詢

    SELECT * FROM eav_entity_store其中entity_type_id在(存在從eav_entity_type中選擇entity_type_id,其中entity_type_code ='invoice');

  2. 如果不存在任何記錄,請從magento後端創建一個虛擬發票。然後,你將有一個記錄表中,現在運行下面的腳本:

    更新eav_entity_store設置increment_last_id = 「YOUR_DESIRED_INVOICE_ID」,increment_prefix = 'X-',其中entity_type_id中(從eav_entity_type選擇entity_type_id其中entity_type_code = '發票')

嘗試了這一點,並創建新的發票:

更新eav_entity_store設置increment_last_id = 「0001」,increment_prefix = '2002',其中entity_type_id中(從eav_entity_type選擇entity_type_id其中entity_type_code = '發票')

http://deepakbhatta.com/magento-set-custom-invoice-id/

這對我來說很好。

謝謝