您好我想知道如何在包含多种产品的订单中获取特定产品的qty_ordered。
我试过这些
$orders = Mage::getModel('sales/order')->getCollection()->
addAttributeToSelect('shipping_description')->
addAttributeToSelect('increment_id')->
addAttributeToSelect('base_grand_total')->
addAttributeToSelect('total_qty_ordered')->
addAttributeToSelect('shipping_address_id')->
addAttributeToSelect('billing_address_id')->
addAttributeToSelect('created_at')->
addAttributeToSelect('shipping_incl_tax')->
addAttributeToFilter('status', 'pending');
但是addAttributeToSelect(' total_qty_ordered') - >总共?哪个产品?
答案 0 :(得分:5)
“total_qty_ordered”总计没有订单中所有产品的订单数量
如果,您想要产品的数量,那么
你可以尝试
<?php $order_id = 2314; //use your own order id
$order = Mage::getModel("sales/order")->load($order_id); //load order by order id
$ordered_items = $order->getAllItems();
foreach($ordered_items as $item){ //item detail
echo $item->getItemId();
//product id
echo $item->getSku();
echo $item->getQtyOrdered();
//ordered qty of item
echo $item->getName();
// etc.
} ?>
答案 1 :(得分:0)
对我而言,它的工作原理如下:
<?php
$_order = $this->getOrder(); //call the order
$order_qty = floor($_order->getData('total_qty_ordered')); //get qty of all items rounded to full number (without 3.0000 or so)
echo $order_qty;
?>
在 template / sales / order / totals.phtml
上使用它答案 2 :(得分:0)
你也可以试试这个: -
json.dumps(json_data["data"])