当有一个订单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()); |
3 |
$address = trim( $order ->getShippingAddress()->getFormated(true)); |
5 |
$items = $order ->getAllItems(); |
8 |
foreach ( $items as $item ) { |
9 |
$products [ "prod" ][] = $item ->getProductId(); |
10 |
$products [ "qty" ][] = $item ->getQtyOrdered(); |
11 |
$total += $item ->getQtyOrdered(); |
13 |
$total = round ( $total ); |