0

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

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

我知道需要填充数据才能运行报告,并且搜索查询将其基于具有“1”或更大的任何项目 - 但数据仍然存在,只是没有与之关联的订单,因此永远不会将其设置在报表查询的适用限制。

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

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

4

3 回答 3

0

扩展程序将为您提供所需的东西。我刚刚购买并安装了它,它工作得很好,但如果你有大量的 SKU,我不推荐它。

于 2014-03-25T00:31:55.947 回答
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
  • 使用多个过滤掉与 someS SKU 匹配的产品cat.sku not like 'SOH%'
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

如果你 100% 确定你可以将它提供给更新语句

伙计们 BACKUP BACKUP Before

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
                )

反馈赞赏

于 2020-08-27T13:02:09.437 回答
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'
于 2020-01-14T12:50:43.873 回答