我怎样才能获得所有购买的magento产品?

时间:2014-03-24 12:20:01

标签: magento product complete

我是magento的新手。这是我的代码:

<?php 
    $_orders = $this->getOrders();
    foreach ($_orders as $_order){ 
        var_dump($_order->getStatus());
    } 
?>

这让我觉得这样:

string(7) "pending" string(10) "processing" string(7) "pending" string(7) "pending" string(7) "pending" string(10) "processing" string(10) "processing" string(7) "pending" string(7) "pending" string(8) "complete" 

但我希望得到所有&#34;完成&#34;物品。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

尝试$order->getState()

$_orders = Mage::getModel('sales/order')->getCollection();
// to get all the completed order you could do 
//$_orders->addFieldToFilter('state', Mage_Sales_Model_Order::STATE_COMPLETE);

foreach ($_orders as $_order){
        var_dump($order->getState());
        var_dump($_order->getData()); // return all field in sale_flat_order table
        //$_order->getStatus() = $_order->getData('status') - return only the status field
}