Magento - 自定义发票号码

3

我需要将默认发票编号从100000001修改为2012 - 00001

我知道在表eav_entity_store中可以找到increment_last_id。但我不知道我必须设置什么才能采用新的发票编号格式。

请给予一些建议。

3个回答

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

这样做,您就不必手动更改数据库结构以实现此目的。希望这能帮助到您。

1

0

更改发票编号的最佳方法是运行以下简单的SQL查询:

  1. 通过运行以下查询检查eav_entity_store表中是否存在发票记录

    select * from eav_entity_store where entity_type_id in (select entity_type_id from eav_entity_type where entity_type_code='invoice');

  2. 如果没有记录,则从Magento后端创建一个虚拟发票。然后您将在表中有一条记录,现在运行以下脚本:

    update eav_entity_store set increment_last_id="YOUR_DESIRED_INVOICE_ID", increment_prefix='X-' where entity_type_id in (select entity_type_id from eav_entity_type where entity_type_code='invoice')

尝试这个并创建新的发票:

update eav_entity_store set increment_last_id="0001", increment_prefix='2002' where entity_type_id in (select entity_type_id from eav_entity_type where entity_type_code='invoice')

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

这对我来说很好用。

谢谢


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接