Magento报告:未订购的产品

时间:2013-09-12 16:50:21

标签: php magento reporting product

所以......如果产品已售出,Native Magento只会导出数据。我们都知道这一点,我们都曾经使用它,处理它,在某个时间点厌恶它。

我需要能够生成一份报告,按销售数量显示所有商品,包括那些从未销售的商品(0或销售数量为零)。我们这样做是为了让我可以从很少出售或从不出售的网站上取出一些物品,这样我们就不会制造故事和两件事。

我理解需要填充数据以运行报告,并且搜索查询将其基于任何具有“1”或更大的项目 - 但是数据仍然存在,那里没有与之关联的订单,因此从不设置它在报告查询的适用限制范围内。

有没有办法修改搜索查询以包含这些“从未销售”的商品或任何其他方法?

我使用的是Magento Enterprise 1.12.02,但报告模板/方法应该是全面相似的 - 如果不是我过去曾设法复制它们。

3 个答案:

答案 0 :(得分:0)

extension可以满足您的需求。 我刚购买并安装它,它的效果很好,但是如果你有大量的SKU,我就不会推荐它。

答案 1 :(得分:0)

使用此MySQL查询,您可以获得未售出产品的列表。

select entity_id, sku, (SELECT value FROM catalog_product_entity_varchar WHERE entity_id = catalog_product_entity.entity_id AND attribute_id = 72) as name
from catalog_product_entity
where entity_id not in (select product_id from sales_flat_order_item group by product_id)

要获取您网站的“名称”属性ID,请运行此查询并替换上述查询中的72

SELECT attribute_id FROM eav_attribute
    WHERE entity_type_id=4 AND attribute_code='name'

答案 2 :(得分:0)

在此查询中进行编辑

  • 产品created_at的日期仅包括使用cat.created_at < "2019-07-01 00:00:00"的特定日期之前添加的产品
  • 包括从未销售过(NULL)或仅在特定日期之前使用sale.created_at IS NULL OR sale.created_at < "2020-01-01 00:00:00"售出的产品
  • 包括使用stock.qty = 0的没有库存的Ony产品
  • 使用多个cat.sku not like 'SOH%'过滤出与某些SKU匹配的产品
SELECT cat.entity_id, cat.sku, cat.created_at as product_created, sale.created_at as last_sold
FROM catalog_product_entity AS cat
LEFT JOIN sales_flat_order_item AS sale ON cat.entity_id = sale.product_id
INNER JOIN cataloginventory_stock_item as stock ON cat.entity_id = stock.product_id
WHERE (sale.created_at IS NULL OR sale.created_at < "2020-01-01 00:00:00")
AND (cat.sku not like 'SOH%' and cat.sku not like 'ML7%' and cat.sku not like 'SOC%' and cat.sku not like 'LL%' and cat.sku not like 'ALG%')
AND cat.created_at < "2019-07-01 00:00:00"
AND cat.entity_id = stock.product_id
AND stock.qty = 0
group by cat.entity_id

如果您百分百确定可以将其提供给更新声明

人备份之前备份

UPDATE catalog_product_entity_int
SET value = 2
WHERE attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = "status" and entity_type_id = 4)
AND entity_id IN (
                    SELECT cat.entity_id
                    FROM catalog_product_entity AS cat
                    LEFT JOIN sales_flat_order_item AS sale ON cat.entity_id = sale.product_id
                    INNER JOIN cataloginventory_stock_item as stock ON cat.entity_id = stock.product_id
                    WHERE (sale.created_at IS NULL OR sale.created_at < "2020-01-01 00:00:00")
                    AND (cat.sku not like 'SOH%' and cat.sku not like 'ML7%' and cat.sku not like 'SOC%' and cat.sku not like 'LL%' and cat.sku not like 'ALG%')
                    AND cat.created_at < "2019-07-01 00:00:00"
                    AND cat.entity_id = stock.product_id
                    AND stock.qty = 0
                    group by cat.entity_id
                )

感谢反馈