出口Magento订单 - 获得折扣金额

时间:2014-11-12 01:15:33

标签: php magento export orders

我有下面显示的自定义PHP代码,可以在Magento中导出订单。我需要此代码才能获得订单的总折扣以及订单中的商品数量。有人可以帮帮我吗?

// !    ----- GET NEW ORDERS -----
$myOrder=Mage::getModel('sales/order'); 
$orders=Mage::getModel('sales/mysql4_order_collection');

//Optional filters you might want to use - more available operations in method _getConditionSql      in Varien_Data_Collection_Db. 
$orders->addFieldToFilter('total_paid',Array('gt'=>0)); //Amount paid larger than 0
$orders->addFieldToFilter('status',Array('eq'=>"processing"));  //Status is "processing"

$allIds=$orders->getAllIds();
foreach($allIds as $thisId) {
$myOrder->reset()->load($thisId);


//Getting Order Fields
echo "'" . $myOrder->getBillingAddress()->getLastname() . "',";
echo "'" . $myOrder->getTotal_paid() . "',";
echo "'" . $myOrder->getShippingAddress()->getTelephone() . "',";
echo "'" . $myOrder->getPayment()->getCc_type() . "',";
echo "'" . $myOrder->getStatus() . "',";
echo "\r\n";
}

1 个答案:

答案 0 :(得分:2)

在加载订单模型时,您可以使用getDiscountAmount方法。

$discount = $myOrder->getDiscountAmount();

您可以从以下位置获取商品数量:

$numberOfOrderItems = count( $myOrder->getAllVisibleItems() );