迁移畅销商品报告

本文档可帮助您从旧版畅销商品报告迁移到新版。用于导出 BestSellers_TopBrands_BestSellers_TopProducts_BestSellers_TopProducts_Inventory_ 表的旧版报告将于 2025 年 9 月 1 日弃用。

新版畅销商品报告提供以下信息:

旧版和新版报告导出的表

下表比较了旧版和新版报告导出的表格:

旧报告 新报告
BestSellers_TopBrands BestSellersBrandWeekly”和“BestSellersBrandMonthly
BestSellers_TopProducts BestSellersProductClusterWeekly”和“BestSellersProductClusterMonthly
BestSellers_TopProducts_Inventory BestSellersEntityProductMapping

旧版报告包含一组汇总的畅销商品数据,涵盖未指定的时间范围。新报告会在请求时提供此类数据的最新周度和月度汇总数据。

比较 BestSellers_TopBrandsBestSellersBrandWeeklyBestSellersBrandMonthly

下表可帮助您确定 BestSellers_TopBrands中在 BestSellersBrandWeeklyBestSellersBrandMonthly 表中具有等效替换项的字段。旧表中的某些字段没有替代项。

BestSellers_TopBrands(旧版) BestSellersBrandWeeklyBestSellersBrandMonthly(新)
rank_timestamp _PARTITIONDATE”和“_PARTITIONTIME
brand brand
google_brand_id
ranking_category category_id
ranking_category_path.locale
ranking_category_path.name
ranking_country country_code
rank_id
rank rank
previous_rank previous_rank
relative_demand.bucket relative_demand
relative_demand.min
relative_demand.max
previous_relative_demand.bucket previous_relative_demand
previous_relative_demand.min
previous_relative_demand.max
relative_demand_change

比较 BestSellers_TopProductsBestSellersProductClusterWeeklyBestSellersProductClusterMonthly

下表可帮助您确定 BestSellers_TopProducts中在 BestSellersProductClusterWeeklyBestSellersProductClusterMonthly 表中具有等效替换项的字段。旧表中的某些字段没有替代项。

BestSellers_TopProducts(旧版) BestSellersProductClusterWeeklyBestSellersProductClusterMonthly(新)
rank_timestamp _PARTITIONDATE”和“_PARTITIONTIME
rank_id entity_id
rank rank
previous_rank previous_rank
ranking_country country_code
ranking_category report_category_id
ranking_category_path.locale
ranking_category_path.name
relative_demand.bucket relative_demand
relative_demand.min
relative_demand.max
previous_relative_demand.bucket previous_relative_demand
previous_relative_demand.min
previous_relative_demand.max
relative_demand_change
product_title.locale
product_title.name title(每个语言区域使用单个标题,而不是数组)
gtins variant_gtins
google_brand_id
brand brand
google_product_category
category_l1category_l2category_l3category_l4category_l5
google_product_category_path.locale
google_product_category_path.name
price_range.min price_range.min_amount_micros
price_range.max price_range.max_amount_micros
price_range.currency price_range.currency_code
product_inventory_status
brand_inventory_status

畅销商品数据的商品目录映射

在旧版畅销商品报告中,畅销商品数据会使用 TopProducts中的 rank_id 列映射到新生成的表中的商家目录数据。

在新版畅销商品报告中,BestSellersProductCluster 表中会导出 entity_id 列,该列会映射到 BestSellersEntityProductMapping 表中商家商品目录中的所有商品 ID。

BestSellers_TopProductsInventory(旧版) BestSellersEntityProductMapping(新)
rank_id(在 BestSellers_TopProducts 中找到) entity_id(可在 BestSellersProductClustersWeeklyBestSellersProductClustersMonthly 表中找到)
product_id product_id
merchant_id
aggregator_id

示例查询

本部分重点介绍了用于检索畅销商品数据的示例查询的变更。

示例 1:检索给定类别和国家/地区的热门商品

以下查询会返回给定类别和国家/地区的热门商品。

使用 BestSellers_TopProducts 表格(旧版)

SELECT
  rank,
  previous_rank,
  relative_demand.bucket,
  (SELECT name FROM top_products.product_title WHERE locale = 'en-US') AS product_title,
  brand,
  price_range,
  google_product_category
FROM
  `DATASET.BestSellers_TopProducts_MERCHANT_ID` AS top_products
WHERE
  _PARTITIONDATE = 'DATE' AND
  ranking_category = 267 /*Smartphones*/ AND
  ranking_country = 'US'
ORDER BY
  rank;

使用 BestSellersProductClusterWeeklyBestSellersProductClusterMonthly 表格(新)

SELECT
  rank,
  previous_rank,
  relative_demand,
  title AS product_title,
  brand,
  price_range,
  category_l1,
  category_l2
FROM
  `DATASET.BestSellersProductClusterWeekly_MERCHANT_ID` AS top_products
WHERE
  _PARTITIONDATE = 'DATE' AND
  report_category_id = 267 /*Smartphones*/ AND
  country_code = 'US'
ORDER BY
  rank;

示例 2:检索商品目录中的热门商品

以下查询会返回商品目录中的热门商品列表。

使用 BestSellers_TopProducts 表格(旧版)

WITH latest_top_products AS
(
  SELECT
    *
  FROM
    `DATASET.BestSellers_TopProducts_MERCHANT_ID`
  WHERE
    _PARTITIONDATE = 'DATE'
),
latest_top_products_inventory AS
(
  SELECT
    *
  FROM
    `DATASET.BestSellers_TopProducts_Inventory_MERCHANT_ID`
  WHERE
    _PARTITIONDATE = 'DATE'
)
SELECT
  top_products.rank,
  inventory.product_id,
  (SELECT ANY_VALUE(name) FROM top_products.product_title) AS product_title,
  top_products.brand,
  top_products.gtins
FROM
  latest_top_products AS top_products
INNER JOIN
  latest_top_products_inventory AS inventory
USING (rank_id);

使用 BestSellersProductClusterWeeklyBestSellersProductClusterMonthly 表格(新)

WITH latest_top_products AS
(
  SELECT
    *
  FROM
    `DATASET.BestSellersProductClusterWeekly_MERCHANT_ID`
  WHERE
    _PARTITIONDATE = 'DATE'
),
latest_top_products_inventory AS
(
  SELECT
    *
  FROM
    `DATASET.BestSellersEntityProductMapping_MERCHANT_ID`
  WHERE
    _PARTITIONDATE = 'DATE'
)
SELECT
  top_products.rank,
  inventory.product_id,
  top_products.title AS product_title,
  top_products.brand,
  top_products.variant_gtins
FROM
  latest_top_products AS top_products
INNER JOIN
  latest_top_products_inventory AS inventory
USING (entity_id);

此外,如果您想查找商品目录中畅销商品或品牌的数量,请使用 product_inventory_statusbrand_inventory_status 列对 BestSellerProductClusterWeeklyBestSellerProductClusterMonthly 表运行查询。请参阅以下示例查询:

SELECT
  *
FROM
  `DATASET.BestSellersProductClusterMonthly_MERCHANT_ID`
WHERE
  _PARTITIONDATE = 'DATE' AND
  product_inventory_status != 'NOT_IN_INVENTORY'
ORDER BY
  rank;

示例 3:检索给定类别和国家/地区的热门品牌

以下查询会返回给定类别和国家/地区的热门品牌列表。

使用 BestSellers_TopBrands 表格(旧版)

SELECT
  rank,
  previous_rank,
  brand
FROM
  `DATASET.BestSellers_TopBrands_MERCHANT_ID`
WHERE
  _PARTITIONDATE = 'DATE' AND
  ranking_category = 267 /*Smartphones*/ AND
  ranking_country = 'US'
ORDER BY
  rank;

使用 BestSellersTopBrandsWeeklyBestSellersTopBrandsMonthly 表格(新)

SELECT
  rank,
  previous_rank,
  brand
FROM
  `DATASET.BestSellersTopBrandsWeekly_MERCHANT_ID`
WHERE
  _PARTITIONDATE = 'DATE' AND
  report_category_id = 267 /*Smartphones*/ AND
  country_code = 'US'
ORDER BY
  rank;

示例 4:检索商品目录中热门品牌的商品

以下查询会返回商品目录中热门品牌的商品列表。

使用 BestSellers_TopBrands 表格(旧版)

WITH latest_top_brands AS
  (
    SELECT
      *
    FROM
      `DATASET.BestSellers_TopBrands_MERCHANT_ID`
    WHERE
      _PARTITIONDATE = 'DATE'
  ),
  latest_products AS
  (
    SELECT
      product.*,
      product_category_id
    FROM
      `DATASET.Products_MERCHANT_ID` AS product,
      UNNEST(product.google_product_category_ids) AS product_category_id,
      UNNEST(destinations) AS destination,
      UNNEST(destination.approved_countries) AS approved_country
    WHERE
      _PARTITIONDATE = 'DATE'
  )
SELECT
  top_brands.brand,
  (SELECT name FROM top_brands.ranking_category_path
  WHERE locale = 'en-US') AS ranking_category,
  top_brands.ranking_country,
  top_brands.rank,
  products.product_id,
  products.title
FROM
  latest_top_brands AS top_brands
INNER JOIN
  latest_products AS products
ON top_brands.google_brand_id = products.google_brand_id AND
   top_brands.ranking_category = product_category_id AND
   top_brands.ranking_country = products.approved_country;

使用 BestSellersTopBrandsWeeklyBestSellersTopBrandsMonthly 表格(新)

WITH latest_top_brands AS
  (
    SELECT
      *
    FROM
      `DATASET.BestSellersBrandMonthly_MERCHANT_ID`
    WHERE
      _PARTITIONDATE = 'DATE'
  ),
  latest_products AS
  (
    SELECT
      product.*,
      product_category_id
    FROM
      `DATASET.Products_MERCHANT_ID` AS product,
      UNNEST(product.google_product_category_ids) AS product_category_id,
      UNNEST(destinations) AS destination,
      UNNEST(destination.approved_countries) AS approved_country
    WHERE
      _PARTITIONDATE = 'DATE'
  )
SELECT
  top_brands.brand,
  - The full category name is not supported in the new BestSellersTopBrands tables.
  - (SELECT name FROM top_brands.ranking_category_path
  - WHERE locale = 'en-US') AS ranking_category,
  top_brands.category_id,
  top_brands.rank,
  products.product_id,
  products.title
FROM
  latest_top_brands AS top_brands
INNER JOIN
  latest_products AS products
ON top_brands.brand = products.brand AND
   top_brands.category_id = product_category_id AND
   top_brands.country_code = products.approved_country;

在以下查询中,替换以下内容:

  • DATASET:您的数据集的名称。
  • MERCHANT_ID:商家账号 ID
  • DATE:日期(采用 YYYY-MM-DD 格式)

后续步骤