【问题标题】:Magento Collection get clients by payment methodMagento Collection 通过付款方式获取客户
【发布时间】:2014-08-04 02:31:31
【问题描述】:

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

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

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

【问题讨论】:

    标签: magento methods collections filter payment


    【解决方案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 加载客户的模型

    【讨论】:

    • 非常感谢 Aleksandr,这很有帮助!我只会做一些调整,因为我必须显示带有客户姓名的付款方式。考虑到这一点,我只会添加一个 foreach 来获取付款方式的标题,并在最后打印出来。
    猜你喜欢
    • 2013-02-21
    • 2014-12-29
    • 2017-09-18
    • 2012-03-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-05
    • 2013-02-15
    • 1970-01-01
    相关资源
    最近更新 更多