OmnichannelSettings API 是設定店面商品目錄廣告 (LIA) 和免費區域產品資訊 (FLL) 計畫的進入點。
以程式輔助方式使用
- 管理 (建立及更新) 全通路設定
- 擷取 (取得和列出) 全通路設定
- 為符合資格的商家申請商品目錄驗證
詳情請參閱「店面商品目錄廣告和免費區域產品資訊總覽」。
必要條件
您應該具備
Merchant Center 帳戶
商家檔案。如果沒有 Google 帳戶,可以建立一個。請參閱「註冊商家檔案」。
商家檔案和 Merchant Center 帳戶之間的連結。如要建立連結,您可以使用 Merchant Center 使用者介面或 Merchant API (請參閱「連結 Google 商家檔案」)。
建立全通路設定
您可以使用 omnichannelSettings.create
方法建立全通路設定。create 方法會將 omnichannelSetting
資源做為輸入內容,並在成功時傳回已建立的全通路設定。
建立時,您必須填入 regionCode
和 LsfType
:
- OmnichannelSetting 是依國家/地區設定。
RegionCode
會定義指定的國家/地區。建立後即無法變更。RegionCode
應遵循 通用區域資料庫 (CLDR) 專案定義的命名規則。 LsfType
以產品頁面為基礎。詳情請參閱LsfType
。
如需詳細資訊,請參閱「變更店面商品目錄廣告的產品網頁類型」。
您不必在建立階段填寫所有欄位,而是可以稍後再進行設定。如要更新現有的 omnichannelSetting
,請參閱「更新全通路設定」。
如果您選擇 MHLSF_BASIC
並註冊 inStock
,以下是要求範例:
POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings
{
"regionCode": "{REGION_CODE}",
"lsfType: "MHLSF_BASIC",
"inStock": {
"uri": "{URI}"
}
}
更改下列內容:
{ACCOUNT_ID}
:Merchant Center 帳戶的專屬 ID{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.v1;
// [START merchantapi_create_omnichannel_setting]
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.AccountName;
import com.google.shopping.merchant.accounts.v1.CreateOmnichannelSettingRequest;
import com.google.shopping.merchant.accounts.v1.InStock;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting.LsfType;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.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
欄位,表示你打算提供附有取貨服務水準協議的產品。我們會根據提供的 URI 開始審查。
以下是使用 Pickup
建立 omnichannel
設定的範例要求:
POST https://merchantapi.googleapis.com/accounts/v1/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/v1/accounts/{ACCOUNT_ID}/omnichannelSettings/{OMNICHANNEL_SETTING}
更改下列內容:
{ACCOUNT_ID}
:Merchant Center 帳戶的專屬 ID{OMNICHANNEL_SETTING}
:指定國家/地區的區碼
ACTIVE
狀態表示審查已獲得核准。
如果狀態為 FAILED
,請解決問題,然後呼叫 omnichannelSetting.update
觸發新的審查程序。
唯讀的 LFP
欄會顯示店面動態饋給合作夥伴狀態。如要連結合作夥伴關係,請使用 lfpProviders.linkLfpProvider
。
如要進一步瞭解如何查看狀態及其含義,請參閱「查看全通路設定的狀態」。
列出全通路設定
如要擷取帳戶的所有 omnichannelSetting
資訊,請使用 omnichannelSettings.list
方法。
程式碼範例如下:
package shopping.merchant.samples.accounts.v1;
// [START merchantapi_list_omnichannel_settings]
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.AccountName;
import com.google.shopping.merchant.accounts.v1.ListOmnichannelSettingsRequest;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient.ListOmnichannelSettingsPagedResponse;
import com.google.shopping.merchant.accounts.v1.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.v1;
// [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.v1.InventoryVerification;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingName;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceSettings;
import com.google.shopping.merchant.accounts.v1.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.v1;
// [START merchantapi_request_inventory_verification]
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingName;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceSettings;
import com.google.shopping.merchant.accounts.v1.RequestInventoryVerificationRequest;
import com.google.shopping.merchant.accounts.v1.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/v1/accounts/{ACCOUNT_ID}/omnichannelSettings/{REGION_CODE}?update_mask=lsf_type,in_stock,pickup
{
"lsfType: "GHLSF",
"inStock": {},
}
更改下列內容:
{ACCOUNT_ID}
:Merchant Center 帳戶的專屬 ID{REGION_CODE}
:CLDR 定義的區域代碼
申請商品目錄驗證
即使更新產品或商品目錄動態饋給並確認聯絡人,InventoryVerification.state
仍與 INACTIVE
不同:
- 奧地利、德國和瑞士的商家:請確認已完成簡介頁面審查。
- 這項作業需要約 48 小時。
- 如果重複檢查商品目錄失敗 (超過五次),服務會強制執行 30 天的冷卻期,之後才會允許其他要求。如要提早申請,請與 Google 支援團隊聯絡。
瞭解詳情
詳情請參閱店面商品目錄廣告和免費區域產品資訊說明中心。