5

我想将客人订单链接到 Magento 中的现有帐户。有人知道我必须更改哪些表上的哪些字段才能完成此操作吗?

有没有更简单的方法?

4

5 回答 5

8

这似乎也有效..

$order_id = 5;  // Your Order ID
$customer_id = 7;  //Customer ID

$_order = Mage::getModel('sales/order')->load($order_id);

if($_order->getCustomerId() == NULL){
    $_order->setCustomerId($customer_id);
    $_order->save();
}
于 2012-10-08T17:58:26.683 回答
6

如果您使用的是 Magento >= 1.4.1,则可以在数据库中运行它:

UPDATE sales_flat_order 
   SET customer_id = YOUR_CUSTOMER_ID_HERE 
WHERE entity_id = YOUR_ORDER_ID_HERE AND customer_id IS NULL

您还需要升级“网格”表:

UPDATE sales_flat_order_grid 
    SET customer_id = YOUR_CUSTOMER_ID_HERE 
WHERE entity_id = YOUR_ORDER_ID_HERE AND customer_id IS NULL
于 2012-07-10T09:59:37.980 回答
3

由于从后端从 order 中获取 increment_id 比从 entity id 中获取更容易,我更喜欢使用以下两个查询:

UPDATE sales_flat_order 
  SET customer_id = YOUR_CUSTOMER_ID_HERE, customer_is_guest=0, customer_group_id = YOUR_CUSTOMER_GROUP_ID_HERE
  WHERE increment_id = YOUR_INCREMENT_ID_HERE AND customer_id IS NULL

UPDATE sales_flat_order_grid 
  SET customer_id = YOUR_CUSTOMER_ID_HERE, 
  WHERE increment_id = YOUR_INCREMENT_ID_HERE AND customer_id IS NULL
于 2015-07-08T11:05:59.983 回答
1

要扩展 RS 发布的内容:

如果您希望管理订单屏幕反映成员所在的组,则需要多几行:

$customer_id = xxxx;  //Customer ID
$order_increment_id = xxxxxxxxx; //Admin order increment id
$_order = Mage::getModel('sales/order')->loadByIncrementId($order_increment_id);

if($_order->getCustomerId() == NULL){
    $_order->setCustomerId($customer_id);
}

if($_order->getCustomerIsGuest() == "1"){
    $_order->setCustomerIsGuest(0);
}

if($_order->getCustomerGroupId() == "0"){
    $_order->setCustomerGroupId(1);
}

$_order->save();
于 2016-02-04T17:50:46.653 回答
0

我正在使用 magento 1.9.0.1 并用于更改以下信息:
对于表sales_flat_order
=> 将customer_id从 NULL 更改为new customer_id
=> customer_is_guest0

同样对于表sales_flat_order_grid
=> 将customer_id从 NULL 更改为新的 customer_id

以下 2 个查询将完成这项工作:

UPDATE sales_flat_order 
  SET customer_id = (Your_Customer_ID), customer_is_guest=0 
  WHERE entity_id = Your_Order_ID_HERE AND customer_id IS NULL

UPDATE sales_flat_order_grid 
  SET customer_id = Your_Customer_ID 
  WHERE entity_id = Your_Order_ID AND customer_id IS NULL
于 2015-07-06T08:10:58.480 回答