【问题标题】:Magento - custom invoice numberMagento - 自定义发票号码
【发布时间】:2012-11-16 13:23:51
【问题描述】:

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

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

请提供一些建议。

【问题讨论】:

    标签: magento invoice


    【解决方案1】:

    如果您想手动操作,请查看@How to Change the Invoice Increment ID and Prefix in Magento(请记住始终进行备份)

    【讨论】:

    • 谢谢。这正是我所需要的。
    【解决方案2】:

    您可以通过编辑以下类来自定义订单/发票/creditmemo/shipment number (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;
    }
    

    这样,您无需手动更改数据库结构中的任何内容即可实现。

    希望这会对您有所帮助。

    【讨论】:

      【解决方案3】:

      更改发票 ID 的最佳方法是运行以下简单的 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/

      这对我来说很好。

      谢谢

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-10-07
        • 2012-08-11
        • 1970-01-01
        • 2015-06-07
        • 2019-08-16
        • 2011-06-28
        相关资源
        最近更新 更多