-
-
Save EHLOVader/6902579 to your computer and use it in GitHub Desktop.
Total number of items sold
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$obj = new Shop_Product(); | |
$obj->select('shop_products.id, sum(shop_order_items.quantity) AS "sold"'); | |
$obj->join('shop_order_items', 'shop_products.id = shop_order_items.shop_product_id'); | |
$obj->join('shop_orders', 'shop_order_items.shop_order_id = shop_orders.id'); | |
$best_selling = $obj->where('shop_orders.payment_processed IS NOT NULL')->group('shop_products.id')->find_all(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment