我在另一个名为laravel的php框架中做了一个类似的报告。查询有点不同,因为它属于laravel,但是你会得到这个概念。我的要求没有特别的价格,所以你不会在这里找到。我会尝试明天编辑答案,并给你一个正确的查询:
$result=DB::table('catalog_product_flat_1 as t1')
->join('sales_flat_order_item as t2', 't1.entity_id', '=', 't2.product_id')
->join('eav_attribute_set as t3','t1.attribute_set_id','=','t3.attribute_set_id')
->join('cataloginventory_stock_status as t4','t1.entity_id','=','t4.product_id')
->select
( 't1.entity_id','t1.sku','t1.name','t1.url_path','t1.created_at',
't1.product_type','t3.attribute_set_name','t1.price','t4.stock_status',
DB::raw('sum(t2.qty_ordered) as sum')
)
您也可以参考我以前的一个问题: Build an sql query for all enabled products in magento database