magento order number 自定义

主要涉及2个表,eav_entity_type和eav_entity_store

SELECT entity_type_id,entity_type_code,increment_pad_length FROM `eav_entity_type` WHERE entity_type_code =’order’;

SELECT * FROM `eav_entity_store`;

一般order很长,第一个increment_pad_length(eav_entity_type)是订单号码除了increment_prefix(eav_entity_store表)的长度。

increment_last_id(eav_entity_type)是系统组后一个订单号码


如果系统已经有了订单,存在了订单号码,可以sql语句更新

参考:

 

mysql_connect(“localhost”,$user,$psw);

mysql_select_db($db);
$store_id=1;
$prefix=’ABC’;
$start_num=’10001′;

$rs=mysql_query(“SELECT * FROM `sales_flat_order` a WHERE a.`store_id`='”.$store_id.”‘”);

while ($rw=mysql_fetch_array($rs))
{
$order_id=$rw[‘entity_id’];
$order_num = $rw[‘increment_id’];
$order_num_new=$prefix.$start_num;
$start_num++;

echo $order_id.'<br/>’;
echo $order_num.'<br/>’;
echo $order_num_new.'<br/>’;

mysql_query(“update `sales_flat_order` set `increment_id`='”.$order_num_new.”‘ where `increment_id`='”.$order_num.”‘”);
mysql_query(“update `sales_flat_order_grid` set `increment_id`='”.$order_num_new.”‘ where `increment_id`='”.$order_num.”‘”);

mysql_query(“update `sales_flat_creditmemo` set `increment_id`='”.$order_num_new.”‘ where `order_id`='”.$order_id.”‘”);
mysql_query(“update `sales_flat_creditmemo_grid` set `increment_id`='”.$order_num_new.”‘,`order_increment_id`='”.$order_num_new.”‘ where `order_id`='”.$order_id.”‘”);
mysql_query(“update `sales_flat_invoice` set `increment_id`='”.$order_num_new.”‘ where `order_id`='”.$order_id.”‘”);
mysql_query(“update `sales_flat_invoice_grid` set `increment_id`='”.$order_num_new.”‘,`order_increment_id`='”.$order_num_new.”‘ where `order_id`='”.$order_id.”‘”);
mysql_query(“update `sales_flat_shipment` set `increment_id`='”.$order_num_new.”‘ where `order_id`='”.$order_id.”‘”);
mysql_query(“update `sales_flat_shipment_grid` set `increment_id`='”.$order_num_new.”‘,`order_increment_id`='”.$order_num_new.”‘ where `order_id`='”.$order_id.”‘”);
}