Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT e.entity_id FROM magento2test.catalog_product_entity as e INNER JOIN magento2test.sales_order_item as soi
- ON e.entity_id = soi.product_id GROUP BY e.entity_id HAVING COUNT(soi.product_id) > 200;
- $reportCountVal = 200;
- $collection = $this->productCollectionFactory->create();
- $collection->getSelect()
- ->joinLeft(
- ['soi' => $collection->getResource()->getTable('sales_order_item')],
- 'e.entity_id = soi.product_id'
- )
- ->group('e.entity_id')
- ->having('COUNT(soi.product_id) > ?', $reportCountVal);
Add Comment
Please, Sign In to add comment