使用SQL在Magento中检索产品详细信息

时间:2016-10-11 07:53:33

标签: mysql sql database magento

我正在为Tableau上的Magento商店运行分析,该商店已连接到数据库。 我试图通过不同的SQL查询(包括目录产品EAV上的左连接)在同一个表(产品ID,SKU,成本,价格和特殊价格)中获取产品详细信息,但仍然无法正确使用

将这些属性组合在一起的SQL查询是什么? (不捆绑产品,只是简单的产品)

我没有在这里发布我的查询,因为我认为逻辑可能影响任何评论。 我知道这是一个艰难的,但提前感谢任何想法。

2 个答案:

答案 0 :(得分:0)

我在另一个称为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

答案 1 :(得分:0)

我使用以下查询对我非常有用:

Select *
From catalog_product_entity, catalog_product_index_price, core_website, customer_group
Where catalog_product_entity.entity_id = catalog_product_index_price.entity_id
and  catalog_product_index_price.website_id = core_website.website_id 
and  catalog_product_index_price.customer_group_id = customer_group.customer_group_id
/* HEIDER: Enable here if you need to filter Store -- and  core_website.code = 'us' */
/* HEIDER: Enable here if you need to filter Customer Group -- and  customer_group.customer_group_code = 'General' */
Order by sku;

我希望这会有所帮助,

H