Guest User

Untitled

a guest
Jun 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. SELECT e.entity_id FROM magento2test.catalog_product_entity as e INNER JOIN magento2test.sales_order_item as soi
  2. ON e.entity_id = soi.product_id GROUP BY e.entity_id HAVING COUNT(soi.product_id) > 200;
  3.  
  4. $reportCountVal = 200;
  5. $collection = $this->productCollectionFactory->create();
  6. $collection->getSelect()
  7. ->joinLeft(
  8. ['soi' => $collection->getResource()->getTable('sales_order_item')],
  9. 'e.entity_id = soi.product_id'
  10. )
  11. ->group('e.entity_id')
  12. ->having('COUNT(soi.product_id) > ?', $reportCountVal);
Add Comment
Please, Sign In to add comment