Omnichannel Settings API adalah titik entri untuk mengonfigurasi program Iklan Inventaris Lokal (LIA) dan Listingan Lokal Gratis (FLL).
Gunakan API ini untuk melakukan tindakan berikut secara terprogram:
- Mengelola (membuat dan memperbarui) Setelan Omnichannel
- Mengambil (mendapatkan dan mencantumkan) Setelan Omnichannel
- Meminta verifikasi inventaris untuk penjual yang memenuhi syarat
Untuk mengetahui informasi selengkapnya, lihat Ringkasan iklan inventaris lokal dan listingan lokal gratis.
Prasyarat
Anda harus memiliki
akun Merchant Center
Profil Bisnis. Jika belum memilikinya, Anda dapat membuatnya. Lihat Mendaftar ke Profil Bisnis.
Tautan antara Profil Bisnis dan akun Merchant Center Anda. Untuk membuat tautan, Anda dapat menggunakan antarmuka pengguna Merchant Center atau Merchant API (lihat Menautkan Profil Bisnis Google).
Membuat setelan omnichannel
Anda dapat menggunakan metode omnichannelSettings.create untuk membuat setelan omnichannel. Metode pembuatan menggunakan resource omnichannelSetting sebagai input dan menampilkan setelan omnichannel yang dibuat, jika berhasil.
Saat membuat, Anda harus mengisi regionCode dan
LsfType:
- OmnichannelSetting berlaku per negara.
RegionCodemenentukan negara target. Setelah dibuat, Anda tidak dapat mengubahnya.RegionCodeharus mengikuti aturan penamaan yang ditentukan oleh project Common Locale Data Repository (CLDR). LsfTypedidasarkan pada halaman produk Anda. Untuk mengetahui detailnya, lihatLsfType.
Untuk mengetahui detail selengkapnya, lihat Mengubah jenis halaman produk untuk iklan inventaris lokal.
Anda tidak harus mengisi semua kolom pada tahap pembuatan, tetapi dapat mengonfigurasinya nanti. Untuk memperbarui omnichannelSetting yang ada, lihat
Memperbarui setelan omnichannel.
Berikut adalah contoh permintaan jika Anda memilih MHLSF_BASIC dan mendaftarkan inStock:
POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings
{
"regionCode": "{REGION_CODE}",
"lsfType: "MHLSF_BASIC",
"inStock": {
"uri": {URI}"
}
}
Ganti kode berikut:
{ACCOUNT_ID}: ID unik akun Merchant Center Anda{REGION_CODE}: Kode wilayah seperti yang ditentukan oleh CLDR{URI}: URI valid yang digunakan untuk peninjauan tertentu. URI yang tidak memenuhi syarat dapat mencegah persetujuan.
Setelah permintaan berhasil dijalankan, Anda akan melihat respons berikut:
{
"name": "accounts/{ACCOUNT_ID}/omnichannelSettings/{omnichannel_setting}",
"regionCode": "{REGION_CODE}",
"lsfType: "MHLSF_BASIC",
"inStock": {
"uri": "{URI}",
"state": "RUNNING"
}
}
Mendaftarkan berbagai fitur LIA/FLL menggunakan kolom omnichannelSetting akan memicu peninjauan manual yang biasanya memerlukan waktu beberapa jam hingga beberapa hari. Sebaiknya periksa kembali input Anda untuk menghindari waktu tunggu yang tidak perlu karena data yang tidak memenuhi syarat.
Untuk melihat setelan omnichannel yang baru dibuat atau memeriksa status peninjauan, gunakan accounts.omnichannelSettings.get atau accounts.omnichannelSettings.list, dengan menentukan negara.
Jenis Halaman Retailer Lokal (LSF)
Berdasarkan jenis halaman produk yang akan Anda gunakan, pilih LsfType:
| Jenis halaman produk | LsfType | Nilai enum |
|---|---|---|
| Halaman produk dengan data ketersediaan di toko | Halaman Retailer Lokal yang Dihosting Penjual (Dasar) | MHLSF_BASIC |
| Halaman produk khusus toko dengan ketersediaan dan harga | Halaman Retailer Lokal yang Dihosting Penjual (Lengkap) | MHLSF_FULL |
| Halaman produk tanpa ketersediaan di toko | Halaman Retailer Lokal yang Dihosting Google (GHLSF) | GHLSF |
Jika memilih jenis Halaman retailer lokal yang dihosting penjual, Anda juga harus mengisi
kolom URI untuk setidaknya salah satu dari inStock atau pickup.
InStock
Anda dapat menggunakan InStock untuk memberikan informasi selengkapnya tentang halaman produk Anda.
Jika Anda memilih jenis LSF yang Dihosting Penjual dan menentukan kolom URI di InStock, Anda menunjukkan niat untuk menayangkan produk dengan data ketersediaan di toko. Kami akan memulai peninjauan berdasarkan URI yang diberikan.
Jika Anda memilih jenis GHLSF, Anda harus memberikan kolom InStock kosong dalam permintaan. Tidak seperti jenis LSF yang Dihosting Penjual, untuk menyelesaikan proses orientasi, Anda harus
menyelesaikan proses Verifikasi Inventaris.
Contoh kode ini membuat omnichannelSetting dengan GHLSF:
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)
Pengambilan
Selain data ketersediaan di toko, Anda juga dapat melengkapi produk di toko dengan fitur Pengambilan, yang hanya memenuhi syarat untuk jenis LSF yang Dihosting Penjual.
Jika produk ditandai untuk Pengambilan, artinya pelanggan dapat membelinya secara online dan mengambilnya di toko. Dengan menetapkan kolom Pickup, Anda menunjukkan niat untuk menayangkan produk dengan perkiraan tanggal ambil. Kami akan memulai peninjauan berdasarkan URI yang diberikan.
Berikut adalah contoh permintaan yang membuat setelan omnichannel dengan Pickup:
POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings
{
"regionCode": "{REGION_CODE}",
"lsfType: "MHLSF_BASIC",
"pickup": {
"uri: "{URI}"
}
}
Produk untuk dipesan saja
Dengan fitur produk untuk dipesan saja, Anda dapat menampilkan produk yang dipajang di toko fisik, tetapi tidak tersedia untuk langsung dibeli. Misalnya, furnitur besar:
- Pelanggan yang mencari produk serupa di Google akan melihat iklan ini dengan anotasi "di toko" dalam hasil penelusuran mereka.
- Pelanggan yang menelusuri toko di halaman hasil Penelusuran Google akan melihat produk ini ditandai sebagai "Tersedia untuk dipesan".
Pelanggan dapat memilih iklan inventaris lokal atau listingan lokal gratis Anda untuk melihat item tersebut. Untuk membeli item, pelanggan dapat mengunjungi toko fisik Anda, melihat item, lalu memesannya untuk dikirim kepada mereka atau ke toko Anda agar dapat diambil.
Tentang (Jerman, Austria, dan Swiss)
Jika Anda menayangkan iklan di Austria dan Jerman serta memilih GHLSF, Anda harus mengirimkan halaman
Tentang.
Jika Anda menayangkan iklan di Swiss, Anda harus mengirimkan halaman "Tentang", terlepas dari LsfType.
Hingga URL halaman Tentang diverifikasi, penjual GHLSF tidak dapat meminta verifikasi inventaris manual dari Google.
Untuk semua penjual di ketiga negara ini, layanan tidak mengaktifkan fitur FLL/LIA hingga halaman Tentang Anda menerima persetujuan.
Verifikasi Inventaris
Verifikasi Inventaris hanya diperlukan untuk penjual GHLSF. Verifikasi ini tidak didukung untuk jenis MHLSF.
Sebelum atau setelah Anda menambahkan data produk dan data inventaris (menggunakan accounts.products.localInventories.insert atau antarmuka pengguna Merchant Center), Anda harus memverifikasi kontak Anda. Berikan kontak verifikasi inventaris (nama dan alamat email) menggunakan metode create atau update. Kontak tersebut akan menerima email yang dikirim oleh Google dan dapat memverifikasi statusnya dengan mengklik tombol dalam pesan.
Setelah menyelesaikan langkah ini, Anda dapat Meminta verifikasi inventaris. Untuk mengetahui informasi selengkapnya, lihat Tentang verifikasi inventaris.
Anda dapat mengubah kontak selama proses verifikasi atau setelah verifikasi menggunakan omnichannelSetting.update.
Setelah proses ini selesai, Google akan memvalidasi akurasi informasi yang diberikan.
Mendapatkan setelan omnichannel
Untuk mengambil konfigurasi omnichannelSetting di negara tertentu, atau memeriksa
status peninjauan Anda saat ini, gunakan metode omnichannelSettings.get.
Berikut adalah contoh permintaan:
GET https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings/{OMNICHANNEL_SETTING}
Ganti kode berikut:
{ACCOUNT_ID}: ID unik akun Merchant Center Anda{OMNICHANNEL_SETTING}: Kode wilayah negara target Anda
Status ACTIVE menunjukkan bahwa peninjauan telah menerima persetujuan.
Jika statusnya FAILED, atasi masalah dan picu peninjauan baru dengan memanggil omnichannelSetting.update.
Kolom LFP yang hanya dapat dibaca menampilkan status Kemitraan Feed Lokal Anda. Untuk menautkan ke kemitraan, gunakan lfpProviders.linkLfpProvider.
Untuk mengetahui informasi selengkapnya tentang cara memeriksa status dan artinya, lihat Melihat status setelan omnichannel.
Mencantumkan Setelan Omnichannel
Untuk mengambil semua informasi omnichannelSetting untuk akun Anda, gunakan metode
omnichannelSettings.list.
Berikut adalah contoh kode:
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)
Memperbarui setelan omnichannel
Untuk memperbarui konfigurasi setelan omnichannel yang ada, gunakan metode omnichannelSettings.update.
Untuk memperbarui, Anda harus menambahkan fitur yang diinginkan ke mask pembaruan, dan mengisi kolom yang sesuai di kolom omnichannelSetting dalam permintaan pembaruan.
Anda dapat memperbarui salah satu dari
lsfTypeinStockpickupodoaboutinventoryVerification
Jika atribut tidak disertakan dalam mask pembaruan, atribut tersebut tidak akan diperbarui.
Jika atribut disertakan dalam mask pembaruan, tetapi tidak ditetapkan dalam permintaan, atribut tersebut akan dihapus.
Contoh kode berikut menunjukkan cara memperbarui kolom verifikasi inventaris.
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)
Meminta verifikasi inventaris
omnichannelSettings.requestInventoryVerification hanya relevan untuk penjual GHLSF.
Sebelum memanggil RPC ini, Anda harus melakukan hal berikut:
- Mengupload data produk dan inventaris Anda.
- Memverifikasi kontak verifikasi inventaris.
- Untuk penjual di Austria, Jerman, atau Swiss, selesaikan peninjauan halaman
About.
Untuk menentukan kelayakan Anda, panggil omnichannelSettings.get dan periksa omnichannelSetting.inventoryVerification.state. Jika statusnya INACTIVE, Anda siap memanggil 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);
}
}
Melihat status setelan omnichannel.
Untuk memeriksa status peninjauan orientasi LIA, periksa ReviewState
untuk atribut omnichannelSetting yang sesuai yang ditampilkan oleh
omnichannelSettings.get atau omnichannelSettings.list metode.
Kolom ReviewState berlaku untuk semua peninjauan orientasi kecuali proses verifikasi inventaris, dan dapat memiliki nilai berikut:
ACTIVE: Disetujui.FAILED: Ditolak.RUNNING: Masih dalam peninjauan.ACTION_REQUIRED: Status ini hanya ada diInStock.stateuntuk penjual GHLSF. Artinya, Anda harus meminta verifikasi inventaris agar LIA dapat ditayangkan.
InventoryVerification.State memiliki nilai berikut:
SUCCEEDED: Disetujui.INACTIVE: Anda siap meminta verifikasi inventaris.RUNNING: Dalam peninjauanSUSPENDED: Anda terlalu sering gagal dalam verifikasi inventaris (biasanya 5 kali), dan harus menunggu sebelum dapat memintanya lagi.ACTION_REQUIRED: Anda harus melakukan tindakan tambahan sebelum meminta verifikasi inventaris.
Memecahkan masalah terkait Omnichannel Settings API
Bagian ini menjelaskan cara memecahkan masalah umum.
Membuat setelan omnichannel
- Pastikan untuk menetapkan
LsfTypedanRegionCode. - Jika Anda memilih
GHLSF, berikanInStockkosong dalam permintaan. - Jika Anda memilih jenis LSF yang Dihosting Penjual, berikan setidaknya satu URI di
InStockatauPickup.
Memperbarui setelan omnichannel
Metode pembaruan untuk resource ini memerlukan aturan tambahan berikut:
- Anda tidak dapat mengubah kode wilayah.
- Anda tidak dapat melakukan pembaruan saat fitur LIA/FLL berjalan atau telah disetujui.
- Saat beralih dari jenis LSF yang Dihosting Penjual ke
GHLSF, jikaInStockdanPickupsebelumnya dikonfigurasi, Anda harus menyertakannya dalam mask pembaruan bersama dengan pembaruanLsfType.
Misalnya, jika Anda sebelumnya menerapkan MHLSF_BASIC dan Pickup, lalu keduanya ditolak, Anda dapat beralih ke GHLSF dengan mengirimkan permintaan seperti ini:
PATCH https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings/{REGION_CODE}?update_mask=lsf_type,in_stock,pickup
{
"lsfType": "GHLSF",
"inStock": {},
}
Ganti kode berikut:
{ACCOUNT_ID}: ID unik akun Merchant Center Anda{REGION_CODE}: Kode wilayah seperti yang ditentukan oleh CLDR
Meminta verifikasi inventaris
Jika, meskipun telah memperbarui feed produk atau inventaris dan mengonfirmasi kontak, InventoryVerification.state bukan INACTIVE:
- Untuk penjual di Austria, Jerman, dan Swiss: Pastikan Anda telah menyelesaikan peninjauan halaman Tentang.
- Akan ada penundaan sekitar 48 jam.
- Jika terjadi kegagalan Pemeriksaan Inventaris Berulang (lebih dari lima kali), layanan akan menerapkan periode tunggu selama tiga puluh hari sebelum mengizinkan permintaan lain. Hubungi Dukungan Google jika Anda ingin memintanya lebih awal.
Pelajari lebih lanjut
Untuk mengetahui detail selengkapnya, lihat Pusat Bantuan iklan inventaris lokal dan listingan lokal gratis.