示例#1
0
 /**
  * Orders quantity data
  *
  * @param array $productIds
  * @return array
  */
 protected function getOrdersData(array $productIds)
 {
     $ordersSubSelect = clone $this->orderResource->getSelect();
     $ordersSubSelect->reset()->from(['oi' => $this->getTable('sales_order_item')], ['product_id', 'orders' => new \Zend_Db_Expr('COUNT(1)')])->where('oi.product_id IN (?)', $productIds)->group('oi.product_id');
     return $this->orderResource->getConnection()->fetchAssoc($ordersSubSelect);
 }
示例#2
0
 /**
  * Add billing agreement filter on orders collection
  *
  * @param \Magento\Sales\Model\ResourceModel\Order\Collection $orderCollection
  * @param string|int|array $agreementIds
  * @return $this
  */
 public function addOrdersFilter(\Magento\Sales\Model\ResourceModel\Order\Collection $orderCollection, $agreementIds)
 {
     $agreementIds = is_array($agreementIds) ? $agreementIds : [$agreementIds];
     $orderCollection->getSelect()->joinInner(['pbao' => $this->getTable('paypal_billing_agreement_order')], 'main_table.entity_id = pbao.order_id', [])->where('pbao.agreement_id IN(?)', $agreementIds);
     return $this;
 }