Omnichannel Settings API הוא נקודת הכניסה להגדרת התוכניות 'מודעות מלאי של חנויות מקומיות' (LIA) ו'כרטיסים חינמיים למוצרים מקומיים' (FLL).
אפשר להשתמש בו כדי
- ניהול (יצירה ועדכון) הגדרות של Omnichannel
- אחזור (get ו-list) של הגדרות Omnichannel
- שליחת בקשה לאימות מלאי למוכרים שעומדים בדרישות
מידע נוסף זמין במאמר סקירה כללית על מודעות מלאי של חנויות מקומיות וכרטיסים חינמיים למוצרים מקומיים.
דרישות מוקדמות
צריך להיות לכם
חשבון Merchant Center
פרופיל עסק. אם אין לכם חשבון, אתם יכולים ליצור אחד. איך נרשמים לפרופיל עסק ב-Google
קישור בין פרופיל העסק לבין חשבון Merchant Center. כדי ליצור את הקישור, אפשר להשתמש בממשק המשתמש של Merchant Center או ב-Merchant API (ראו קישור פרופיל העסק ב-Google).
יצירת הגדרה בכל הערוצים
אפשר להשתמש ב-method 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"
}
}
הפעלת תכונות שונות של LIA/FLL באמצעות שדות omnichannelSetting מפעילה בדיקות ידניות, שבדרך כלל נמשכות כמה שעות או כמה ימים. מומלץ לבדוק שוב את הנתונים שהזנתם כדי להימנע מזמן המתנה מיותר בגלל נתונים שלא עומדים בדרישות.
כדי לראות את הגדרת האומניצ'אנל החדשה שיצרתם או לבדוק את סטטוס הביקורות,
משתמשים ב-accounts.omnichannelSettings.get או ב-accounts.omnichannelSettings.list ומציינים את המדינה.
סוג דף של חנות מקומית (LSF)
בהתאם לדף המוצר שבו אתם מתכננים להשתמש, בוחרים באפשרות LsfType:
| סוג דף המוצר | LsfType | ערך enum |
|---|---|---|
| דפי מוצר עם נתוני זמינות במלאי | דף של חנות מקומית באתר של המוכר (בסיסי) | MHLSF_BASIC |
| דפי מוצר עם נתוני מחיר וזמינות במלאי בחנות ספציפית | דף של חנות מקומית באתר של המוכר (מלא) | MHLSF_FULL |
| דפי מוצר ללא נתוני זמינות במלאי | דף של חנות מקומית שמתארח ב-Google (GHLSF) | GHLSF |
אם בוחרים באחד מסוגי דפי החנות באתר של המוכר, צריך גם למלא את שדה ה-URI לפחות באחת מהאפשרויות inStock או pickup.
InStock
אתם יכולים להשתמש ב-InStock כדי לספק מידע נוסף על דף המוצר.
אם בחרתם בסוגי דפי LSF שמתארחים באתר המוכר וציינתם את שדה ה-URI במאפיין InStock, אתם מביעים את הכוונה להציג מוצרים עם זמינות במלאי. נתחיל בבדיקה על סמך ה-URI שצוין.
אם בוחרים בסוג GHLSF, צריך לספק שדה InStock ריק בבקשה. בניגוד לסוגי דפי נחיתה עם תכונות של חנות מקומית שמתארחים בדומיין של המוכר, כדי להשלים את תהליך ההצטרפות צריך להשלים את תהליך אימות המלאי.
בדוגמת הקוד הזו נוצר omnichannelSetting באמצעות 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)
איסוף
בנוסף לנתוני הזמינות במלאי, אתם יכולים לשפר את חוויית הרכישה של המוצרים בחנות באמצעות התכונה 'איסוף במועד מאוחר יותר', שזמינה רק לסוגי דפי מוצר עם נתוני זמינות במלאי שמתארחים באתר שלכם.
כשמוצר מסומן לאיסוף, זה אומר שלקוח יכול לקנות אותו אונליין ולאסוף אותו מהחנות. הגדרת השדה Pickup מעידה על הכוונה שלכם להציג מוצרים עם תאריך זמינות לאיסוף. נתחיל בבדיקה על סמך ה-URI שסיפקת.
זוהי בקשה לדוגמה שיוצרת הגדרת omnichannel עם Pickup:
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 -
{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
ב-Google.
לפני שמבצעים את ה-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, בודקים את ReviewState
המאפיינים התואמים של omnichannelSetting שמוחזרים על ידי השיטות omnichannelSettings.get או omnichannelSettings.list.
השדה ReviewState רלוונטי לכל הבדיקות של תהליך ההצטרפות, חוץ מתהליך האימות של מלאי שטחי הפרסום, והוא יכול לכלול את הערכים הבאים:
-
ACTIVE: הוא אושר. -
FAILED: ההצעה נדחית. -
RUNNING: עדיין בבדיקה. -
ACTION_REQUIRED: המאפיין הזה קיים רק ב-InStock.stateאצל מוכרים שמשתמשים ב-GHLSF. המשמעות היא שצריך לבקש אימות מלאי כדי שמודעת LIA תוכנס לשימוש בסביבת הייצור.
InventoryVerification.State יכול לקבל את הערכים הבאים:
-
SUCCEEDED: הוא אושר. INACTIVE: אפשר לבקש אימות מלאי.RUNNING: בבדיקה-
SUSPENDED: נכשלתם באימות המלאי יותר מדי פעמים (בדרך כלל 5), ועליכם להמתין לפני שתוכלו לבקש אותו שוב. -
ACTION_REQUIRED: צריך לבצע פעולות נוספות לפני שמבקשים אימות מלאי.
פתרון בעיות שקשורות ל-Omnichannel Settings API
בקטע הזה מוסבר איך לפתור בעיות נפוצות.
יצירת הגדרה בכל הערוצים
- חשוב להגדיר גם את
LsfTypeוגם אתRegionCode. - אם בוחרים באפשרות
GHLSF, צריך לספק בקשה ריקהInStock. - אם בוחרים סוגים של LSF שמתארחים אצל המוכר, צריך לספק לפחות URI אחד ב-
InStockאו ב-Pickup.
עדכון הגדרה של ערוצים משולבים
שיטת העדכון של המשאב הזה מחייבת את הכללים הנוספים הבאים:
- אי אפשר לשנות את קוד האזור.
- אי אפשר לבצע עדכונים בזמן שהתכונה 'פרסום מוצרים למכירה בחנויות מקומיות' פועלת או שאושרה.
- כשמשנים מסוגי 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 שעות.
- אם בדיקת המלאי נכשלת שוב ושוב (יותר מחמש פעמים), המערכת תחיל תקופת צינון של 30 יום לפני שתאפשר בקשה נוספת. אפשר לפנות לתמיכה של Google כדי לבקש שההחזר יועבר מוקדם יותר.
מידע נוסף
פרטים נוספים זמינים במרכז העזרה בנושא מודעות מלאי של חנויות מקומיות וכרטיסים חינמיים למוצרים מקומיים.