从order中得到 Customer 和 Product Info

来源:互联网 发布:linux 创建线程 编辑:程序博客网 时间:2024/05/02 13:13

当有一个订单order,我们想在中间处理一下,得到customer和product的信息,或者做点别的事情,需要懂之间的关系,下面是一段参考代码,从order中得到 Customer 和 Product Info,大致怎么使用magento的items

  
1$orderid = "1000000054";
2$orderid = round(substr($orderid, 1));
3$order = Mage::getModel('sales/order')->load($orderid);

 

1<pre>$orderid= "1000000054";
2$order = Mage::getModel('sales/order')->loadByIncrementId($orderid);</pre>

 

1$giftMessage = Mage::getModel("giftmessage/message")->load($order->getGiftMessageId());
2// then use echo $giftMessage->getMessage();
3$address = trim($order->getShippingAddress()->getFormated(true));
4// then just echo $address (will give you it formatted with \n separating lines)
5$items = $order->getAllItems();
6$total=0;
7$products =array();
8foreach ($itemsas $item) {
9$products["prod"][] =$item->getProductId();
10$products["qty"][] =$item->getQtyOrdered();
11$total += $item->getQtyOrdered();
12}
13$total = round($total);
14// then you have an array of products with id's and corresponding qty's
15// also echo out the total number of qty's in your order
原创粉丝点击