在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"); } }
更改订单前缀,发票等其他请参考
: