/** * Retrieve billing agreements collection * * @return \Magento\Paypal\Model\Resource\Billing\Agreement\Collection */ public function getBillingAgreements() { if ($this->_billingAgreements === null) { $this->_billingAgreements = $this->_agreementCollection->create()->addFieldToFilter('customer_id', $this->_customerSession->getCustomerId())->setOrder('agreement_id', 'desc'); } return $this->_billingAgreements; }
/** * Prepare collection for grid * * @return $this */ protected function _prepareCollection() { /** @var \Magento\Paypal\Model\Resource\Billing\Agreement\Collection $collection */ $collection = $this->_agreementFactory->create()->addCustomerDetails(); $this->setCollection($collection); return parent::_prepareCollection(); }
/** * Retrieve available customer Billing Agreements * * @param int $customerId * @return \Magento\Paypal\Model\Resource\Billing\Agreement\Collection */ public function getAvailableCustomerBillingAgreements($customerId) { $collection = $this->_billingAgreementFactory->create(); $collection->addFieldToFilter('customer_id', $customerId)->addFieldToFilter('status', self::STATUS_ACTIVE)->setOrder('agreement_id'); return $collection; }