Omnichannel Settings API は、ローカル在庫広告(LIA)と無料ローカル リスティング(FLL)プログラムを設定するためのエントリ ポイントです。
プログラムで
- オムニチャネル設定の管理(作成と更新)
- オムニチャネル設定を取得(取得して一覧表示)する
- 対象となる販売者の在庫確認をリクエストする
詳しくは、ローカル在庫広告と無料ローカル リスティングの概要をご覧ください。
前提条件
次のものが必要です。
Merchant Center アカウント
ビジネス プロフィール。アカウントをお持ちでない場合は、作成できます。ビジネス プロフィールに登録するをご覧ください。
ビジネス プロフィールと Merchant Center アカウント間のリンク。リンクを作成するには、Merchant Center のユーザー インターフェースまたは Merchant API を使用します(Google ビジネス プロフィールをリンクするを参照)。
オムニチャネル設定を作成する
omnichannelSettings.create メソッドを使用して、オムニチャネル設定を作成できます。create メソッドは omnichannelSetting リソースを入力として受け取り、成功した場合は作成されたオムニチャネル設定を返します。
作成時には、regionCode と LsfType の両方を入力する必要があります。
- OmnichannelSetting は国ごとに設定されます。
RegionCodeは対象国を定義します。作成後に変更することはできません。RegionCodeは、Common Locale Data Repository(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 アカウントの一意の識別子{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 のいずれか 1 つ以上の URI フィールドも入力する必要があります。
InStock
InStock を使用すると、商品ページに関する詳細情報を提供できます。
Merchant-Hosted LSF タイプを選択し、InStock で URI フィールドを指定すると、在庫ありの商品を販売する意向を示すことになります。指定された URI に基づいて審査を開始します。
GHLSF タイプを選択した場合は、リクエストで空の InStock フィールドを指定する必要があります。販売者ホスト型の LSF タイプとは異なり、オンボーディングを完了するには、在庫確認の手続きを完了する必要があります。
このコードサンプルは、GHLSF を使用して omnichannelSetting を作成します。
Java
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 credentials retrieved above.
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 occured: ");
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);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\OmnichannelSettingsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\CreateOmnichannelSettingRequest;
use Google\Shopping\Merchant\Accounts\V1\InStock;
use Google\Shopping\Merchant\Accounts\V1\OmnichannelSetting;
use Google\Shopping\Merchant\Accounts\V1\OmnichannelSetting\LsfType;
/**
* This class demonstrates how to create an omnichannel setting for a given
* Merchant Center account in a given country.
*/
class CreateOmnichannelSetting
{
/**
* Helper to create the parent string.
*
* @param string $accountId The merchant account ID.
* @return string The parent string in the format `accounts/{account}`.
*/
private static function getParent(string $accountId): string
{
return sprintf('accounts/%s', $accountId);
}
/**
* Creates an omnichannel setting for a given Merchant Center account.
*
* @param array $config The configuration file for authentication.
* @param string $regionCode The country for the omnichannel setting.
*/
public static function createOmnichannelSettingSample(
array $config,
string $regionCode
): void {
// Obtains OAuth credentials from the configuration file.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Creates a client.
$omnichannelSettingsServiceClient = new OmnichannelSettingsServiceClient([
'credentials' => $credentials
]);
// Constructs the parent resource name.
$parent = self::getParent($config['accountId']);
// Creates the omnichannel setting with GHLSF type in the given country.
$omnichannelSetting = new OmnichannelSetting([
'region_code' => $regionCode,
'lsf_type' => LsfType::GHLSF,
'in_stock' => new InStock()
]);
// Creates the request.
$request = new CreateOmnichannelSettingRequest([
'parent' => $parent,
'omnichannel_setting' => $omnichannelSetting
]);
// Calls the API and prints the response.
try {
printf("Sending create omnichannel setting request:%s", PHP_EOL);
$response = $omnichannelSettingsServiceClient->createOmnichannelSetting($request);
printf("Inserted Omnichannel Setting below:%s", PHP_EOL);
print $response->serializeToJsonString(true) . PHP_EOL;
} catch (ApiException $e) {
printf("An error has occured: %s", $e->getMessage());
}
}
/**
* Executes the sample.
*/
public function callSample(): void
{
$config = Config::generateConfig();
// The country which you're targeting.
$regionCode = '{REGION_CODE}';
self::createOmnichannelSettingSample($config, $regionCode);
}
}
// Runs the script.
$sample = new CreateOmnichannelSetting();
$sample->callSample();
Python
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import CreateOmnichannelSettingRequest
from google.shopping.merchant_accounts_v1 import InStock
from google.shopping.merchant_accounts_v1 import OmnichannelSetting
from google.shopping.merchant_accounts_v1 import OmnichannelSettingsServiceClient
def create_omnichannel_setting(account_id: str, region_code: str) -> None:
"""Creates an omnichannel setting for a given Merchant Center account.
Args:
account_id: The ID of the Merchant Center account.
region_code: The country for which you're creating the setting.
"""
# Gets OAuth Credentials.
credentials = generate_user_credentials.main()
# Creates a client.
client = OmnichannelSettingsServiceClient(credentials=credentials)
# The parent account under which to create the setting.
parent = f"accounts/{account_id}"
# Creates an omnichannel setting with GHLSF type in the given country.
omnichannel_setting = OmnichannelSetting()
omnichannel_setting.region_code = region_code
omnichannel_setting.lsf_type = OmnichannelSetting.LsfType.GHLSF
omnichannel_setting.in_stock = InStock()
# Creates the request.
request = CreateOmnichannelSettingRequest(
parent=parent, omnichannel_setting=omnichannel_setting
)
# Makes the request and catches and prints any error messages.
try:
print("Sending create omnichannel setting request:")
response = client.create_omnichannel_setting(request=request)
print("Inserted Omnichannel Setting below:")
print(response)
except RuntimeError as e:
print("An error has occured: ")
print(e)
if __name__ == "__main__":
# The ID of the account to get the omnichannel settings for.
_ACCOUNT = configuration.Configuration().read_merchant_info()
# The country which you're targeting.
_REGION_CODE = "{REGION_CODE}"
create_omnichannel_setting(_ACCOUNT, _REGION_CODE)
受け取り
店舗の在庫状況に加えて、店舗内商品の販売を促進するために、店舗受け取り機能を使用することもできます。この機能は、販売者がホストする 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 にかかわらず [概要] ページを送信する必要があります。
概要ページの URL の確認が完了するまで、GHLSF の販売者は Google に手動の在庫確認をリクエストできません。
これらの 3 か国のすべての販売者について、[概要] ページが承認されるまで、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 アカウントの一意の識別子{OMNICHANNEL_SETTING}: 対象国の地域コード
ACTIVE ステータスは、審査が承認されたことを示します。
ステータスが FAILED の場合は、問題を解決し、omnichannelSetting.update を呼び出して新しい審査をトリガーします。
読み取り専用の LFP フィールドには、ローカル フィード パートナーシップのステータスが表示されます。パートナーシップにリンクするには、lfpProviders.linkLfpProvider を使用します。
ステータスとその意味を確認する方法については、オムニチャネル設定のステータスを表示するをご覧ください。
オムニチャネル設定の一覧表示
アカウントのすべての omnichannelSetting 情報を取得するには、omnichannelSettings.list メソッドを使用します。
コードサンプルは次のとおりです。
Java
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 credentials retrieved above.
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 occured: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
omnichannelSettings(config);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\OmnichannelSettingsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\ListOmnichannelSettingsRequest;
/**
* This class demonstrates how to get the list of omnichannel settings for a
* given Merchant Center account.
*/
class ListOmnichannelSettings
{
/**
* Helper to create the parent string.
*
* @param string $accountId The merchant account ID.
* @return string The parent string in the format `accounts/{account}`.
*/
private static function getParent(string $accountId): string
{
return sprintf('accounts/%s', $accountId);
}
/**
* Lists the omnichannel settings for a given Merchant Center account.
*
* @param array $config The configuration file for authentication.
*/
public static function listOmnichannelSettingsSample(array $config): void
{
// Obtains OAuth credentials from the configuration file.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Creates a client.
$omnichannelSettingsServiceClient = new OmnichannelSettingsServiceClient([
'credentials' => $credentials
]);
// Constructs the parent resource name.
$parent = self::getParent($config['accountId']);
// Creates the request.
$request = new ListOmnichannelSettingsRequest(['parent' => $parent]);
// Calls the API and prints the response.
try {
printf("Sending list omnichannel setting request:%s", PHP_EOL);
$response = $omnichannelSettingsServiceClient->listOmnichannelSettings($request);
$count = 0;
// Iterates over all the omnichannel settings and prints them.
foreach ($response->iterateAllElements() as $omnichannelSetting) {
print $omnichannelSetting->serializeToJsonString(true) . PHP_EOL;
$count++;
}
printf("The following count of elements were returned: %d%s", $count, PHP_EOL);
} catch (ApiException $e) {
printf("An error has occured: %s", $e->getMessage());
}
}
/**
* Executes the sample.
*/
public function callSample(): void
{
$config = Config::generateConfig();
self::listOmnichannelSettingsSample($config);
}
}
// Runs the script.
$sample = new ListOmnichannelSettings();
$sample->callSample();
Python
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import ListOmnichannelSettingsRequest
from google.shopping.merchant_accounts_v1 import OmnichannelSettingsServiceClient
def list_omnichannel_settings(account_id: str) -> None:
"""Lists the omnichannel settings for a given Merchant Center account.
Args:
account_id: The ID of the Merchant Center account.
"""
# Gets OAuth Credentials.
credentials = generate_user_credentials.main()
# Creates a client.
client = OmnichannelSettingsServiceClient(credentials=credentials)
# The parent account for which to list the settings.
parent = f"accounts/{account_id}"
# Creates the request.
request = ListOmnichannelSettingsRequest(parent=parent)
# Makes the request and catches and prints any error messages.
try:
print("Sending list omnichannel setting request:")
response = client.list_omnichannel_settings(request=request)
count = 0
# Iterates over all the entries in the response.
for omnichannel_setting in response:
print(omnichannel_setting)
count += 1
print(f"The following count of elements were returned: {count}")
except RuntimeError as e:
print("An error has occured: ")
print(e)
if __name__ == "__main__":
# The ID of the account to get the omnichannel settings for.
_ACCOUNT = configuration.Configuration().read_merchant_info()
list_omnichannel_settings(_ACCOUNT)
オムニチャネル設定を更新する
既存のオムニチャネル設定の構成を更新するには、omnichannelSettings.update メソッドを使用します。
更新するには、更新マスクに追加する機能を指定し、更新リクエストの omnichannelSetting フィールドで対応するフィールドに入力する必要があります。次のいずれかを更新できます。
lsfTypeinStockpickupodoaboutinventoryVerification
更新マスクに含まれていない属性は更新されません。
更新マスクに含まれているが、リクエストで設定されていない属性はクリアされます。
次のコードサンプルは、在庫確認フィールドを更新する方法を示しています。
Java
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 credentials retrieved above.
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 occured: ");
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);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
use Google\Shopping\Merchant\Accounts\V1\Client\OmnichannelSettingsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\InventoryVerification;
use Google\Shopping\Merchant\Accounts\V1\OmnichannelSetting;
use Google\Shopping\Merchant\Accounts\V1\UpdateOmnichannelSettingRequest;
/**
* This class demonstrates how to update an omnichannel setting for a given
* Merchant Center account in a given country.
*/
class UpdateOmnichannelSetting
{
/**
* Helper to create the name string.
*
* @param string $accountId The merchant account ID.
* @param string $regionCode The region code of the setting.
* @return string The name string in the format
* `accounts/{account}/omnichannelSettings/{omnichannelSetting}`.
*/
private static function getName(string $accountId, string $regionCode): string
{
return sprintf('accounts/%s/omnichannelSettings/%s', $accountId, $regionCode);
}
/**
* Updates an omnichannel setting for a given Merchant Center account.
*
* @param array $config The configuration file for authentication.
* @param string $regionCode The country of the omnichannel setting.
* @param string $contact The name of the inventory verification contact.
* @param string $email The email of the inventory verification contact.
*/
public static function updateOmnichannelSettingSample(
array $config,
string $regionCode,
string $contact,
string $email
): void {
// Obtains OAuth credentials from the configuration file.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Creates a client.
$omnichannelSettingsServiceClient = new OmnichannelSettingsServiceClient([
'credentials' => $credentials
]);
// Constructs the resource name.
$name = self::getName($config['accountId'], $regionCode);
// Creates the omnichannel setting with the updated fields.
$omnichannelSetting = new OmnichannelSetting([
'name' => $name,
'inventory_verification' => new InventoryVerification([
'contact' => $contact,
'contact_email' => $email
])
]);
// Creates the field mask to specify which fields to update.
$fieldMask = new FieldMask([
'paths' => ['inventory_verification']
]);
// Creates the request.
$request = new UpdateOmnichannelSettingRequest([
'omnichannel_setting' => $omnichannelSetting,
'update_mask' => $fieldMask
]);
// Calls the API and prints the response.
try {
printf("Sending update omnichannel setting request:%s", PHP_EOL);
$response = $omnichannelSettingsServiceClient->updateOmnichannelSetting($request);
printf("Updated Omnichannel Setting below:%s", PHP_EOL);
print $response->serializeToJsonString(true) . PHP_EOL;
} catch (ApiException $e) {
printf("An error has occured: %s", $e->getMessage());
}
}
/**
* Executes the sample.
*/
public function callSample(): void
{
$config = Config::generateConfig();
// The country which you're targeting.
$regionCode = '{REGION_CODE}';
// The name of the inventory verification contact you want to update.
$contact = '{NAME}';
// The address of the inventory verification email you want to update.
$email = '{EMAIL}';
self::updateOmnichannelSettingSample($config, $regionCode, $contact, $email);
}
}
// Runs the script.
$sample = new UpdateOmnichannelSetting();
$sample->callSample();
Python
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.protobuf import field_mask_pb2
from google.shopping.merchant_accounts_v1 import InventoryVerification
from google.shopping.merchant_accounts_v1 import OmnichannelSetting
from google.shopping.merchant_accounts_v1 import OmnichannelSettingsServiceClient
from google.shopping.merchant_accounts_v1 import (
UpdateOmnichannelSettingRequest,
)
def update_omnichannel_setting(
account_id: str, region_code: str, contact: str, email: str
) -> None:
"""Updates an omnichannel setting for a given Merchant Center account.
Args:
account_id: The ID of the Merchant Center account.
region_code: The country for which you're updating the setting.
contact: The name of the inventory verification contact.
email: The email of the inventory verification contact.
"""
# Gets OAuth Credentials.
credentials = generate_user_credentials.main()
# Creates a client.
client = OmnichannelSettingsServiceClient(credentials=credentials)
# The name of the omnichannel setting to update.
name = f"accounts/{account_id}/omnichannelSettings/{region_code}"
# Creates an omnichannel setting with the updated values.
omnichannel_setting = OmnichannelSetting()
omnichannel_setting.name = name
omnichannel_setting.inventory_verification = InventoryVerification(
contact=contact, contact_email=email
)
# Creates a field mask to specify which fields to update.
field_mask = field_mask_pb2.FieldMask(paths=["inventory_verification"])
# Creates the request.
request = UpdateOmnichannelSettingRequest(
omnichannel_setting=omnichannel_setting, update_mask=field_mask
)
# Makes the request and catches and prints any error messages.
try:
print("Sending update omnichannel setting request:")
response = client.update_omnichannel_setting(request=request)
print("Updated Omnichannel Setting below:")
print(response)
except RuntimeError as e:
print("An error has occured: ")
print(e)
if __name__ == "__main__":
# The ID of the account to get the omnichannel settings for.
_ACCOUNT = configuration.Configuration().read_merchant_info()
# The country which you're targeting.
_REGION_CODE = "{REGION_CODE}"
# The name of the inventory verification contact you want to update.
_CONTACT = "{NAME}"
# The address of the inventory verification email you want to update.
_EMAIL = "{EMAIL}"
update_omnichannel_setting(_ACCOUNT, _REGION_CODE, _CONTACT, _EMAIL)
在庫確認をリクエストする
omnichannelSettings.requestInventoryVerification は GHLSF の販売者にのみ関連します。
この RPC を呼び出す前に、次の操作を行う必要があります。
- 商品データと在庫データをアップロードします。
- 在庫確認用の連絡先を確認します。
- オーストリア、ドイツ、スイスの販売者は、
Aboutページの審査を完了します。
利用資格を確認するには、omnichannelSettings.get を呼び出して omnichannelSetting.inventoryVerification.state を確認します。INACTIVE が表示されたら、omnichannelSettings.requestInventoryVerification を呼び出す準備が整っています。
Java
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 credentials retrieved above.
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 occured: ");
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);
}
}
オムニチャネル設定のステータスを表示します。
LIA オンボーディング審査のステータスを確認するには、omnichannelSettings.get メソッドまたは omnichannelSettings.list メソッドから返された omnichannelSetting の対応する属性の ReviewState を確認します。
ReviewState フィールドは、在庫確認プロセスを除くすべてのオンボーディング審査に適用され、次の値を指定できます。
ACTIVE: 承認されています。FAILED: 拒否されます。RUNNING: まだ審査中です。ACTION_REQUIRED: これは、GHLSF 加盟店のInStock.stateにのみ存在します。つまり、ローカル在庫広告を配信するには在庫確認をリクエストする必要があります。
InventoryVerification.State には次の値があります。
SUCCEEDED: 承認されています。INACTIVE: 在庫確認をリクエストする準備が整いました。RUNNING: 審査中ですSUSPENDED: 在庫確認に何度も失敗したため(通常は 5 回)、再度リクエストできるようになるまで待つ必要があります。ACTION_REQUIRED: 在庫確認をリクエストする前に、追加の操作を行う必要があります。
Omnichannel Settings API に関する問題のトラブルシューティング
このセクションでは、一般的な問題のトラブルシューティング方法について説明します。
オムニチャネル設定を作成する
LsfTypeとRegionCodeの両方を設定してください。GHLSFを選択した場合は、リクエストで空のInStockを指定します。- 販売者ホスト型の LSF タイプを選択した場合は、
InStockまたはPickupに URI を 1 つ以上指定します。
オムニチャネル設定を更新する
このリソースの更新メソッドには、次の追加ルールが必要です。
- 地域コードは変更できません。
- 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 アカウントの一意の識別子{REGION_CODE}: CLDR で定義されている地域コード
在庫確認をリクエストする
商品フィードまたは在庫フィードを更新し、連絡先を確認しても、InventoryVerification.state が INACTIVE 以外の場合:
- オーストリア、ドイツ、スイスの販売者様: 概要ページの審査が完了していることを確認してください。
- 約 48 時間の遅延が発生します。
- 在庫確認が 5 回以上連続して失敗した場合は、別のリクエストを許可する前に 30 日間のクールダウン期間が適用されます。早期の払い戻しをご希望の場合は、Google サポートにお問い合わせください。
その他の情報
詳しくは、ローカル在庫広告と無料ローカル リスティングのヘルプセンターをご覧ください。