magento 自定義訂單前綴或訂單起始編號


在magento里訂單的起始號是從1000000001開始的,但有時你可能需要自定義該值的起始號如從 20000000000開始
在Google上搜索了一番找到以下代碼並完美解決問題,以此記錄希望幫助其他有需要的朋友。
在更改數據庫時請對數據庫進行備份
--參考:How To Change Order Prefix And Default Value Of Order/Shipment/Invoice Number/Credit Memo In Magento --自定義magento訂單號起始值,increment_last_id最大為varchar(50)

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='20000000000'
WHERE eav_entity_type.entity_type_code='order';
--自定義訂單前綴,increment_prefix最大為varchar(20)
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_prefix='Htl_'
WHERE eav_entity_type.entity_type_code='order';

 

 
 
本來問題已經通過國外朋友的blog解決,但想在中國就沒有遇到過該問題的朋友,於是在Google上搜索“magento 自定義 訂單號”
果然又找到另一種解決方案(用當前時間來代替訂單號) 此解決方案我並沒有進行測試
--找到該文件\includes\src\Mage_Eav_Model_Entity_Increment_Numeric.php
<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Mage
 * @package     Mage_Eav
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
/**
 * Enter description here...
 *
 * Properties:
 * - prefix
 * - pad_length
 * - pad_char
 * - last_id
 */
class Mage_Eav_Model_Entity_Increment_Numeric extends Mage_Eav_Model_Entity_Increment_Abstract
{
    public function getNextId()
    {
        /*
        $last = $this->getLastId();
        if (strpos($last, $this->getPrefix()) === 0) {
            $last = (int)substr($last, strlen($this->getPrefix()));
        } else {
            $last = (int)$last;
        }
        $next = $last+1;
        return $this->format($next);
       */
        --htl add 2014-10-23 自定義訂單號為當前系統時間
        --此定義的訂單號將導致eav_entity_store.increment_last_id和eav_entity_store.increment_prefix 無效
        --當前你也可以跟當前時間重新組成新的訂單號並返回如:return $this->getPrefix().date("YmdHis");
        --參考 magento插件-將訂單號改為日期流水號

     return date("YmdHis"); } }

 

更改訂單前綴,發票等其他請參考

來自為知筆記(Wiz)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM