OmnichannelSettings API 是配置本地商品目录广告 (LIA) 和非付费本地商品详情 (FLL) 计划的入口点。
以编程方式使用
- 管理(创建和更新)全渠道设置
- 提取(获取和列出)全渠道设置
- 为符合条件的商家申请商品目录核实
如需了解详情,请参阅本地商品目录广告和非付费本地商品详情概览。
前提条件
您应该具备以下条件
Merchant Center 账号
商家资料。如果您还没有 Google 账号,可以创建一个。请参阅注册商家资料。
商家资料与 Merchant Center 账号之间的关联。如需建立关联,您可以使用 Merchant Center 界面或 Merchant API(请参阅关联 Google 商家资料)。
创建全渠道设置
您可以使用 omnichannelSettings.create
方法创建全渠道设置。create 方法将 omnichannelSetting
资源作为输入,并在成功时返回创建的全渠道设置。
创建时,您必须同时填写 regionCode
和 LsfType
:
- OmnichannelSetting 是按国家/地区设置的。
RegionCode
用于定义目标国家/地区。此 ID 一经创建便无法更改。RegionCode
应遵循 Common Locale Data Repository (CLDR) 项目定义的命名规则。 LsfType
是根据您的商品页面提供的。如需了解详情,请参阅LsfType
。
如需了解详情,请参阅更改本地商品目录广告的商品页面体验。
您不必在创建阶段填写所有字段,而是可以稍后进行配置。如需更新现有 omnichannelSetting
,请参阅更新全渠道设置。
如果您选择 MHLSF_BASIC
并注册 inStock
,则请求示例如下:
POST https://merchantapi.googleapis.com/accounts/v1beta/accounts/{ACCOUNT_ID}/omnichannelSettings
{
"regionCode": "{REGION_CODE}",
"lsfType: "MHLSF_BASIC",
"inStock": {
"uri": "{URI}"
}
}
替换以下内容:
{ACCOUNT_ID}
:您的 Merchant Center 账号的唯一标识符{REGION_CODE}
:CLDR 定义的地区代码{URI}
:用于给定评价的有效 URI。不符合条件的 URI 可能会导致应用无法获得批准。
请求成功运行后,您应该会看到以下响应:
{
"name": "accounts/{ACCOUNT_ID}/omnichannelSettings/{omnichannel_setting}",
"regionCode": "{REGION_CODE}",
"lsfType: "MHLSF_BASIC",
"inStock": {
"uri": "{URI}",
"state": "RUNNING"
}
}
使用 omnichannelSetting
字段注册不同的 LIA/FLL 功能会触发人工审核,这通常需要几个小时到几天的时间。我们建议您仔细检查输入内容,以免因数据不符合条件而造成不必要的等待时间。
如需查看新创建的全渠道设置或检查评价状态,请使用 accounts.omnichannelSettings.get
或 accounts.omnichannelSettings.list
,并指定国家/地区。
本地店面页面 (LSF) 类型
根据您打算使用的商品页面,选择 LsfType
:
商品页面类型 | LsfType | 枚举值 |
---|---|---|
显示实体店库存状况的商品页面 | 商家自管的本地店面页面(基本版) | MHLSF_BASIC |
显示库存状况和价格的具体实体店商品页面 | 商家自管的本地店面页面(完整版) | MHLSF_FULL |
不显示实体店库存状况的商品页面 | Google 托管的本地店面页面 (GHLSF) | GHLSF |
如果您选择“商家自管的本地店面”类型,则还需要为 inStock
或 pickup
中的至少一个填写 URI 字段。
InStock
您可以使用 InStock 在商品页面中提供更多信息。
如果您选择商家托管的 LSF 类型,并在 InStock 中指定 URI 字段,则表示您打算投放有货的商品。我们将根据提供的 URI 开始审核。
如果您选择 GHLSF
类型,则需要在请求中提供一个空的 InStock
字段。与商家托管的 LSF 类型不同,若要完成初始配置,您需要完成商品目录验证流程。
以下代码示例使用 GHLSF
创建了 omnichannelSetting
:
package shopping.merchant.samples.accounts.v1beta;
// [START merchantapi_create_omnichannel_setting]
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1beta.AccountName;
import com.google.shopping.merchant.accounts.v1beta.CreateOmnichannelSettingRequest;
import com.google.shopping.merchant.accounts.v1beta.InStock;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSetting;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSetting.LsfType;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSettingsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to create an omnichannel setting for a given Merchant Center account
* in a given country
*/
public class CreateOmnichannelSettingSample {
public static void createOmnichannelSetting(Config config, String regionCode) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the retrieved credentials.
OmnichannelSettingsServiceSettings omnichannelSettingsServiceSettings =
OmnichannelSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Calls the API and catches and prints any network failures/errors.
try (OmnichannelSettingsServiceClient omnichannelSettingsServiceClient =
OmnichannelSettingsServiceClient.create(omnichannelSettingsServiceSettings)) {
String accountId = config.getAccountId().toString();
String parent = AccountName.newBuilder().setAccount(accountId).build().toString();
// Creates an omnichannel setting with GHLSF type in the given country.
CreateOmnichannelSettingRequest request =
CreateOmnichannelSettingRequest.newBuilder()
.setParent(parent)
.setOmnichannelSetting(
OmnichannelSetting.newBuilder()
.setRegionCode(regionCode)
.setLsfType(LsfType.GHLSF)
.setInStock(InStock.getDefaultInstance())
.build())
.build();
System.out.println("Sending create omnichannel setting request:");
OmnichannelSetting response =
omnichannelSettingsServiceClient.createOmnichannelSetting(request);
System.out.println("Inserted Omnichannel Setting below:");
System.out.println(response);
} catch (Exception e) {
System.out.println("An error has occurred: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
// The country which you're targeting at.
String regionCode = "{REGION_CODE}";
createOmnichannelSetting(config, regionCode);
}
}
// [END merchantapi_list_omnichannel_settings]
自取
除了实体店库存状况之外,您还可以使用自提功能来提升实体店商品的展示效果。此功能仅适用于商家托管的 LSF 类型。
如果商品标记为“门店自提”,则表示客户可以在线购买该商品,然后在实体店内自提。设置 Pickup
字段表示您打算提供设有自提服务等级协议 (SLA) 的商品。我们将根据提供的 URI 开始审核。
以下示例请求使用 Pickup
创建 omnichannel
设置:
POST https://merchantapi.googleapis.com/accounts/v1beta/accounts/{ACCOUNT_ID}/omnichannelSettings
{
"regionCode": "{REGION_CODE}",
"lsfType: "MHLSF_BASIC",
"pickup": {
"uri: "{URI}"
}
}
样品,仅接受预定
借助样品,仅接受预定功能,您可以展示已在实体店内展示但不能直接购买的商品。例如,大型家具:
- 客户在 Google 上搜索类似的商品时,将会在搜索结果中看到这类广告带有“实体店有售”注释。
- 如果客户通过 Google 搜索结果页浏览商店页面,会看到这类商品标有“可订购”字样。
他们可以选择您的本地商品目录广告或非付费本地商品详情来查看此类商品。 如要购买此类商品,他们可以前往您的实体店、查看商品,然后订购商品并选择配送至自己的地址或配送到您的商店并自提。
简介(德国、奥地利和瑞士)
如果您在奥地利和德国投放广告并选择 GHLSF
,则必须提交简介页面。
如果您在瑞士投放广告,无论 LsfType
如何,都必须提交“关于”页面。
在“简介”页面网址通过验证之前,GHLSF
商家无法向 Google 申请手动验证商品目录。
对于这三个国家/地区的所有商家,在您的“关于”页面获得批准之前,该服务不会启用 FLL/LIA 功能。
商品目录核实
只有 GHLSF
商家需要进行商品目录核实。MHLSF
类型不支持此方法。
在添加商品数据和商品目录数据(使用 accounts.products.localInventories.insert
或 Merchant Center 界面)之前或之后,您都必须验证联系人。使用 create
或 update
方法提供商品目录验证联系人(姓名和电子邮件地址)。联系人会收到 Google 发送的电子邮件,并能够通过点击邮件中的按钮来验证其状态。
完成此操作后,您可以申请商品目录核实。如需了解详情,请参阅商品目录验证简介。
您可以在验证过程中或验证后使用 omnichannelSetting.update
更改联系人。
此流程完成后,Google 会验证所提供信息的准确性。
获取全渠道设置
如需检索特定国家/地区的 omnichannelSetting
配置,或检查评价的当前状态,请使用 omnichannelSettings.get
方法。
以下是请求示例:
GET https://merchantapi.googleapis.com/accounts/v1beta/accounts/{ACCOUNT_ID}/omnichannelSettings/{OMNICHANNEL_SETTING}
替换以下内容:
{ACCOUNT_ID}
:您的 Merchant Center 账号的唯一标识符{OMNICHANNEL_SETTING}
:目标国家/地区的地区代码
ACTIVE
状态表示审核已获得批准。
如果状态为 FAILED
,请解决问题,然后调用 omnichannelSetting.update
以触发新的审核。
只读 LFP
字段会显示您的本地 Feed 合作伙伴关系状态。如需关联到合作伙伴,请使用 lfpProviders.linkLfpProvider
。
如需详细了解如何查看状态及其含义,请参阅查看全渠道设置的状态。
列出全渠道设置
如需检索账号的所有 omnichannelSetting
信息,请使用 omnichannelSettings.list
方法。
下面是一个代码示例:
package shopping.merchant.samples.accounts.v1beta;
// [START merchantapi_list_omnichannel_settings]
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1beta.AccountName;
import com.google.shopping.merchant.accounts.v1beta.ListOmnichannelSettingsRequest;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSetting;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSettingsServiceClient.ListOmnichannelSettingsPagedResponse;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSettingsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to get the list of omnichannel settings for a given Merchant Center
* account
*/
public class ListOmnichannelSettingsSample {
public static void omnichannelSettings(Config config) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the retrieved credentials.
OmnichannelSettingsServiceSettings omnichannelSettingsServiceSettings =
OmnichannelSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
String accountId = config.getAccountId().toString();
String parent = AccountName.newBuilder().setAccount(accountId).build().toString();
// Calls the API and catches and prints any network failures/errors.
try (OmnichannelSettingsServiceClient omnichannelSettingsServiceClient =
OmnichannelSettingsServiceClient.create(omnichannelSettingsServiceSettings)) {
ListOmnichannelSettingsRequest request =
ListOmnichannelSettingsRequest.newBuilder().setParent(parent).build();
System.out.println("Sending list omnichannel setting request:");
ListOmnichannelSettingsPagedResponse response =
omnichannelSettingsServiceClient.listOmnichannelSettings(request);
int count = 0;
// Iterates over all the entries in the response.
for (OmnichannelSetting omnichannelSetting : response.iterateAll()) {
System.out.println(omnichannelSetting);
count++;
}
System.out.println(String.format("The following count of elements were returned: %d", count));
} catch (Exception e) {
System.out.println("An error has occurred: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
omnichannelSettings(config);
}
}
// [END merchantapi_list_omnichannel_settings]
更新全渠道设置
如需更新现有全渠道设置的配置,请使用 omnichannelSettings.update
方法。
如需进行更新,您必须将所需的地图项添加到更新掩码中,并在更新请求的 omnichannelSetting
字段中填写相应字段。您可以更新以下任意一项:
lsfType
inStock
pickup
odo
about
inventoryVerification
如果某个属性未包含在更新掩码中,则该属性不会更新。
如果某个属性包含在更新掩码中,但未在请求中设置,则该属性将被清除。
以下代码示例演示了如何更新目录验证字段。
package shopping.merchant.samples.accounts.v1beta;
// [START merchantapi_update_omnichannel_setting]
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.protobuf.FieldMask;
import com.google.shopping.merchant.accounts.v1beta.InventoryVerification;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSetting;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSettingName;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSettingsServiceSettings;
import com.google.shopping.merchant.accounts.v1beta.UpdateOmnichannelSettingRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to update an omnichannel setting for a given Merchant Center account
* in a given country
*/
public class UpdateOmnichannelSettingSample {
public static void updateOmnichannelSettings(
Config config, String regionCode, String contact, String email) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the retrieved credentials.
OmnichannelSettingsServiceSettings omnichannelSettingsServiceSettings =
OmnichannelSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Calls the API and catches and prints any network failures/errors.
try (OmnichannelSettingsServiceClient omnichannelSettingsServiceClient =
OmnichannelSettingsServiceClient.create(omnichannelSettingsServiceSettings)) {
String accountId = config.getAccountId().toString();
String name =
OmnichannelSettingName.newBuilder()
.setAccount(accountId)
.setOmnichannelSetting(regionCode)
.build()
.toString();
OmnichannelSetting omnichannelSetting =
OmnichannelSetting.newBuilder()
.setName(name)
.setInventoryVerification(
InventoryVerification.newBuilder()
.setContact(contact)
.setContactEmail(email)
.build())
.build();
FieldMask fieldMask = FieldMask.newBuilder().addPaths("inventory_verification").build();
UpdateOmnichannelSettingRequest request =
UpdateOmnichannelSettingRequest.newBuilder()
.setOmnichannelSetting(omnichannelSetting)
.setUpdateMask(fieldMask)
.build();
System.out.println("Sending update omnichannel setting request:");
OmnichannelSetting response =
omnichannelSettingsServiceClient.updateOmnichannelSetting(request);
System.out.println("Updated Omnichannel Setting below:");
System.out.println(response);
} catch (Exception e) {
System.out.println("An error has occurred: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
// The country which you're targeting at.
String regionCode = "{REGION_CODE}";
// The name of the inventory verification contact you want to update.
String contact = "{NAME}";
// The address of the inventory verification email you want to update.
String email = "{EMAIL}";
updateOmnichannelSettings(config, regionCode, contact, email);
}
}
// [END merchantapi_update_omnichannel_setting]
申请商品目录核实
omnichannelSettings.requestInventoryVerification
仅适用于 GHLSF
商家。
在调用此 RPC 之前,您需要执行以下操作:
- 上传您的商品和商品目录数据。
- 验证商品目录核实联系人。
- 如果您是奥地利、德国或瑞士的商家,请完成
About
页面审核。
如需确定您是否符合条件,请调用 omnichannelSettings.get
并检查 omnichannelSetting.inventoryVerification.state
。如果显示 INACTIVE
,则表示您可以调用 omnichannelSettings.requestInventoryVerification
。
package shopping.merchant.samples.accounts.v1beta;
// [START merchantapi_request_inventory_verification]
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSettingName;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSettingsServiceSettings;
import com.google.shopping.merchant.accounts.v1beta.RequestInventoryVerificationRequest;
import com.google.shopping.merchant.accounts.v1beta.RequestInventoryVerificationResponse;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to request inventory verification for a given Merchant Center account
* in a given country
*/
public class RequestInventoryVerificationSample {
public static void requestInventoryVerification(Config config, String regionCode)
throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the retrieved credentials.
OmnichannelSettingsServiceSettings omnichannelSettingsServiceSettings =
OmnichannelSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Calls the API and catches and prints any network failures/errors.
try (OmnichannelSettingsServiceClient omnichannelSettingsServiceClient =
OmnichannelSettingsServiceClient.create(omnichannelSettingsServiceSettings)) {
String accountId = config.getAccountId().toString();
String name =
OmnichannelSettingName.newBuilder()
.setAccount(accountId)
.setOmnichannelSetting(regionCode)
.build()
.toString();
RequestInventoryVerificationRequest request =
RequestInventoryVerificationRequest.newBuilder().setName(name).build();
System.out.println("Sending request inventory verification request:");
RequestInventoryVerificationResponse response =
omnichannelSettingsServiceClient.requestInventoryVerification(request);
System.out.println("Omnichannel Setting after inventory verification request below:");
System.out.println(response);
} catch (Exception e) {
System.out.println("An error has occurred: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
// The country which you're targeting at.
String regionCode = "{REGION_CODE}";
requestInventoryVerification(config, regionCode);
}
}
// [END merchantapi_request_inventory_verification]
查看全渠道设置的状态。
如需查看 LIA 初始配置审核的审核状态,请检查 ReviewState
,确认 omnichannelSettings.get
或 omnichannelSettings.list
方法返回的 omnichannelSetting
是否具有相应的属性。
ReviewState
字段适用于商品目录验证流程以外的所有初始配置审核,并且可以具有以下值:
ACTIVE
:已获批准。FAILED
:遭拒。RUNNING
:仍在审核中。ACTION_REQUIRED
:此字段仅在 GHLSF 商家的InStock.state
中存在。这意味着,您需要申请商品目录核实,才能投放 LIA。
InventoryVerification.State
具有以下值:
SUCCEEDED
:已获批准。INACTIVE
:您可以申请商品目录核实了。RUNNING
:正在接受审核SUSPENDED
:您商品目录核实失败的次数过多(通常为 5 次),需要等待一段时间才能再次申请核实。ACTION_REQUIRED
:您需要先执行其他操作,然后才能申请商品目录验证。
排查与 OmnichannelSettings
API 相关的问题
本部分介绍了如何排查常见问题。
创建全渠道设置
- 请务必同时设置
LsfType
和RegionCode
。 - 如果您选择
GHLSF
,请在请求中提供空的InStock
。 - 如果您选择商家托管的 LSF 类型,请在
InStock
或Pickup
中提供至少一个 URI。
更新全渠道设置
此资源的更新方法需要遵循以下额外规则:
- 您无法修改地区代码。
- 在 LIA/FLL 功能运行或已获批准期间,您无法进行更新。
- 从商家托管的 LSF 类型更改为
GHLSF
时,如果之前配置了InStock
和Pickup
,您必须将它们与LsfType
更新一起添加到更新掩码中。
例如,如果您之前申请了 MHLSF_BASIC
和 Pickup
,但被拒绝了,则可以发送如下请求,切换到 GHLSF
:
PATCH https://merchantapi.googleapis.com/accounts/v1beta/accounts/{ACCOUNT_ID}/omnichannelSettings/{REGION_CODE}?update_mask=lsf_type,in_stock,pickup
{
"lsfType: "GHLSF",
"inStock": {},
}
替换以下内容:
{ACCOUNT_ID}
:您的 Merchant Center 账号的唯一标识符{REGION_CODE}
:CLDR 定义的地区代码
申请商品目录核实
如果您更新了商品或商品目录 Feed 并确认了联系人,但 InventoryVerification.state
与 INACTIVE
不同,请执行以下操作:
- 对于奥地利、德国和瑞士的商家:请确保您已完成“简介”页面审核。
- 大约需要 48 小时。
- 如果库存检查失败次数过多(超过 5 次),该服务会强制执行 30 天的冷却期,然后才允许再次发出请求。如果您想提前申请,请与 Google 支持团队联系。
了解详情
如需了解详情,请参阅本地商品目录广告和非付费本地商品详情帮助中心。