Omnichannel Settings API هي نقطة الدخول إلى إعداد برامج "إعلانات للمنتجات داخل المتجر" (LIA) و"البيانات المحلية المجانية" (FLL).
استخدِمها بشكل آلي
- إدارة (إنشاء وتعديل) إعدادات "القناة الشاملة"
- استرداد (الحصول على قائمة) إعدادات "القناة الشاملة"
- طلب التحقّق من معلومات المخزون للتجّار المؤهّلين
لمزيد من المعلومات، يمكنك الاطّلاع على نظرة عامة حول "إعلانات للمنتجات داخل المتجر" والبيانات المحلية المجانية.
المتطلبات الأساسية
يجب أن يكون لديك
حساب على Merchant Center
ملف تجاري إذا لم يكن لديك حساب، يمكنك إنشاء حساب. اطّلِع على مقالة الاشتراك في "الملف التجاري على Google".
رابط بين ملفك التجاري وحسابك على Merchant Center لإنشاء الرابط، يمكنك استخدام واجهة مستخدم Merchant Center أو Merchant API (راجِع ربط ملف تجاري على Google).
إنشاء إعدادات قناة التسويق الشاملة
يمكنك استخدام طريقة omnichannelSettings.create لإنشاء إعدادات متعددة القنوات. تتلقّى طريقة الإنشاء مورد omnichannelSetting كإدخال وتعرض إعدادات القنوات المتعددة التي تم إنشاؤها، إذا تمت العملية بنجاح.
عند إنشاء السمة، يجب ملء كل من regionCode وLsfType:
- يتم تفعيل OmnichannelSetting على مستوى كل بلد. تحدّد السمة
RegionCodeالبلد المستهدَف. بعد إنشاء هذا الاسم، لا يمكنك تغييره. يجب أن تتّبعRegionCodeقاعدة التسمية المحدّدة في مشروع مستودع بيانات المواقع الجغرافية المشتركة (CLDR). - تستند خدمة
LsfTypeإلى صفحة المنتج. للحصول على التفاصيل، يُرجى الاطّلاع علىLsfType.
لمزيد من التفاصيل، اطّلِع على مقالة تغيير تجربة صفحة المنتجات التي تقدّمها "الإعلانات للمنتجات المتوفرة في المتجر".
لست بحاجة إلى ملء جميع الحقول في مرحلة الإنشاء، بل يمكنك إعدادها لاحقًا. لتعديل omnichannelSetting حالي، راجع
تعديل إعداد قناة تسويق شاملة.
في ما يلي نموذج طلب إذا اخترت MHLSF_BASIC واشتركت في
inStock:
POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings
{
"regionCode": "{REGION_CODE}",
"lsfType: "MHLSF_BASIC",
"inStock": {
"uri": {URI}"
}
}
غيِّر القيم في السلسلة على الشكل التالي:
{ACCOUNT_ID}: المعرّف الفريد لحسابك على Merchant Center{REGION_CODE}: رمز منطقة وفقًا لتعريف CLDR{URI}: معرّف موارد منتظم صالح يُستخدَم للمراجعة المحدّدة. قد يؤدي معرّف الموارد المنتظم (URI) غير المؤهَّل إلى عدم الموافقة على التطبيق.
بعد تنفيذ الطلب بنجاح، من المفترض أن يظهر لك الردّ التالي:
{
"name": "accounts/{ACCOUNT_ID}/omnichannelSettings/{omnichannel_setting}",
"regionCode": "{REGION_CODE}",
"lsfType: "MHLSF_BASIC",
"inStock": {
"uri": "{URI}",
"state": "RUNNING"
}
}
يؤدي تسجيل ميزات مختلفة من ميزات "إعلانات للمنتجات داخل المتجر (LIA)" أو "المنتجات المتوفرة داخل المتجر" باستخدام حقول omnichannelSetting إلى بدء مراجعات يدوية تستغرق عادةً من بضع ساعات إلى بضعة أيام. ننصحك بالتحقّق من صحة البيانات التي أدخلتها لتجنُّب الانتظار غير الضروري بسبب بيانات غير مؤهَّلة.
لعرض إعدادات القنوات المتعددة التي تم إنشاؤها حديثًا أو التحقّق من حالة المراجعات، استخدِم accounts.omnichannelSettings.get أو accounts.omnichannelSettings.list مع تحديد البلد.
نوع واجهة المحل المجاور (LSF)
استنادًا إلى صفحة المنتج التي تخطّط لاستخدامها، اختَر LsfType:
| نوع صفحة المنتج | LsfType | قيمة التعداد |
|---|---|---|
| صفحات المنتجات مع عرض التوفّر في المتجر | واجهة محلّ محلية يستضيفها تاجر (أساسية) | MHLSF_BASIC |
| صفحات منتجات تعرض معلومات التوفّر والسعر في متجر معيّن | واجهة محلّ محلية يستضيفها تاجر (كاملة) | MHLSF_FULL |
| صفحات المنتجات التي لا تعرض معلومات التوفّر في المتجر | واجهة محلّ مجاور تستضيفها Google (GHLSF) | GHLSF |
في حال اختيار أنواع واجهة المحلّ المحلية التي يستضيفها التاجر، عليك أيضًا ملء حقل URI بواحد على الأقل من inStock أو pickup.
InStock
يمكنك استخدام InStock لتقديم المزيد من المعلومات عن صفحة منتجك.
إذا اخترت أنواع Merchant-Hosted LSF وحدّدت حقل URI في InStock، ستُظهر نيتك في عرض المنتجات المتوفّرة. سنبدأ المراجعة استنادًا إلى عنوان URI المقدَّم.
في حال اختيار النوع GHLSF، عليك توفير حقل InStock فارغ في الطلب. على عكس أنواع خلاصات المنتجات المستضافة لدى التاجر، عليك إكمال عملية التحقّق من معلومات المخزون لإكمال عملية الإعداد.
تنشئ عينة التعليمات البرمجية هذه omnichannelSetting مع GHLSF:
جافا
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 المقدَّم.
في ما يلي نموذج طلب ينشئ إعداد 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.
إلى أن يتم تأكيد عنوان URL الخاص بالصفحة "لمحة"، لا يمكن للتجّار في 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.
لمزيد من المعلومات حول التحقّق من الحالات ومعانيها، يُرجى الاطّلاع على عرض حالة أحد إعدادات القنوات المتعددة.
List Omnichannel Settings
لاسترداد جميع معلومات omnichannelSetting الخاصة بحسابك، استخدِم طريقة omnichannelSettings.list.
في ما يلي عينة تعليمات برمجية:
جافا
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
إذا لم يتم تضمين سمة في قناع التعديل، لن يتم تعديلها.
إذا تم تضمين سمة في قناع التعديل، ولكن لم يتم ضبطها في الطلب، سيتم محوها.
يوضّح نموذج الرمز البرمجي التالي كيفية تعديل حقل التحقق من معلومات المخزون.
جافا
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.
قبل طلب إجراء هذه العملية عن بُعد، عليك تنفيذ ما يلي:
- حمِّل بيانات منتجاتك ومخزونك.
- التحقق من جهة اتصال التحقق من معلومات المخزون.
- بالنسبة إلى التجّار في ألمانيا أو النمسا أو سويسرا، يجب إكمال مراجعة صفحة
About.
لتحديد أهليتك، يُرجى الاتصال بالرقم omnichannelSettings.get والتحقّق من
omnichannelSetting.inventoryVerification.state. إذا ظهرت INACTIVE، يمكنك الاتصال بـ omnichannelSettings.requestInventoryVerification.
جافا
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);
}
}
عرض حالة إعداد القنوات الشاملة
للاطّلاع على حالة مراجعات إعداد ميزة "الإعلانات داخل المتجر"، تحقَّق من 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 المستضافة من التاجر، يجب تقديم معرّف موارد موحّد واحد على الأقل في
InStockأوPickup.
تعديل إعدادات القنوات المتعددة
تتطلّب طريقة التعديل لهذا المرجع القواعد الإضافية التالية:
- لا يمكنك تعديل رمز المنطقة.
- لا يمكنك إجراء تعديلات أثناء تشغيل ميزة إعلانات للمنتجات داخل المتجر (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 ساعة تقريبًا.
- في حال تكرار حالات تعذُّر إجراء فحص المستودع (أكثر من خمس مرات)، تفرض الخدمة فترة انتظار مدتها ثلاثون يومًا قبل السماح بتقديم طلب آخر. يُرجى التواصل مع فريق الدعم في Google إذا أردت تقديم طلب لاسترداد رصيد الاتصال قبل ذلك الوقت.
مزيد من المعلومات
لمزيد من التفاصيل، يُرجى الاطّلاع على مركز مساعدة "إعلانات للمنتجات داخل المتجر" والبيانات المحلية المجانية.