如何使用付款方式“checkmo”领取订单?我可以使用addFieldToFilter函数吗?

谢谢。

最佳答案

使用以下代码:

     $ordersByPaymentCheckMo = Mage::getResourceModel('sales/order_payment_collection')
        ->addFieldToSelect('*')
        ->addFieldToFilter('method',"checkmo");

    foreach($ordersByPaymentCheckMo as $orderByPayment):
          $order = Mage::getModel('sales/order')->load($orderByPayment->getParentId());
         echo '<br/>ORDER # : '.$order->getIncrementId();
    endforeach;

更新最好的方法是加入集合:
    $table_prefix = Mage::getConfig()->getTablePrefix();
    $order_table = $table_prefix.'sales_flat_order';
    $on_condition = "main_table.parent_id = $order_table.entity_id";

    $orderCollection =  Mage::getModel('sales/order_payment')->getCollection()->addFieldToFilter('method',"checkmo");

    $orderCollection ->getSelect()->join($order_table,$on_condition);

    foreach($orderCollection as $order):
     echo '<br/>ORDER # : '.$order->getIncrementId();
    endforeach;

关于Magento : Get orders by specific payment method,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15249099/

10-09 09:31