Magento Collection通过付款方式获取客户

时间:2014-06-13 13:46:53

标签: magento methods collections filter payment

我想知道是否有人已编码Magento Collection以通过付款方式获取客户名称?我使用了下面的代码,现在我有了我需要的付款方式,现在我只需得到客户的名字和姓氏。谢谢大家的帮助。

$collection = Mage::getResourceModel('sales/order_payment_collection')
                                               ->addFieldToSelect('*');

  foreach ($collection as $method) {
      if ($method->getMethod() == "mundipagg_boleto") {
           print $method->getMethod()."<br>";
      }
  }

1 个答案:

答案 0 :(得分:1)

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

  foreach ($collection as $orderPayment) {
      $orderId = $orderPayment->getParentId();
      $order = Mage::getModel('sales/order')->load($orderId);
      $customerId = $order->getCustomerId();
  }

之后,您可以通过customerId加载客户的模型