我需要在订单循环中获取订单商品,如何实现这一点,这是我的代码
$orderCollection = Mage::getModel("sales/order")->getCollection();
foreach ($orderCollection as $order) {
$orders['orders'][] = array(
'id' => $order->getIncrementId(),
'store' => 'magento',
'status' => $order->getStatus(),
'name' => $order->getCustomerName(),
'email' => $order->getCustomerEmail(),
'telephone' => $order->getShippingAddress()->getTelephone(),
'street' => $order->getShippingAddress()->getStreet(),
'pincode' => $order->getShippingAddress()->getPostcode(),
'city' => $order->getShippingAddress()->getCity(),
'weight' => $order->getWeight(),
);
foreach ($order->getAllItems() as $item) {
$orders['items'][] = array(
'id' => $order->getIncrementId(),
'name' => $item->getName(),
'sku' => $item->getSku(),
'Price' => $item->getPrice(),
'Ordered Qty' => $item->getQtyOrdered(),
);
}
}
return $orders;
}
我需要将这两者结合在一个数组中,并在同一数组中显示订单和订单项。
如果我有2个订单数据,如何遍历foreach循环
—
user75563 '18