我正在使用Magento CE 1.9.x,我目前的网站在Magento CE 1.4.x上运行
数据迁移后,每个订单中都缺少客户ID。
现在我想按顺序更新客户ID,我该怎么做?
任何想法?
答案 0 :(得分:0)
以下是有关如何以编程方式更新每个订单的客户ID的示例
$orderCustomerMapping = array(
1 => 123,
2 => 124,
// ...
// order_id => customer_id
);
foreach ($orderCustomerMapping as $orderId => $customerId) {
$order = Mage::getModel('sales/order')->load($orderId);
$order->setCustomerId($customerId);
$order->save();
}
答案 1 :(得分:0)
jraisanen的回答是正确的,但要完成关联,您还应该设置客户组ID并且是这样的访客标志:
$_order = Mage::getModel('sales/order')->load($order->getId());
$_order->setCustomerId($myCustomerId); //sets the customer id
$_order->setCustomerIsGuest(0); //sets is guest to false
$_order->setCustomerGroupId('1');//sets to the "general" customer group
$_order->save();