Omnichannel Settings API هو نقطة الدخول إلى إعداد برامج "الإعلانات للمنتجات المتوفرة في المتجر" (LIA) و"البيانات المحلية المجانية" (FLL).
يمكنك استخدامه لإجراء ما يلي آليًا:
- إدارة إعدادات القنوات المتعددة (إنشاؤها وتعديلها)
- جلب إعدادات القنوات المتعددة (الحصول عليها وعرضها)
- طلب التحقق من معلومات المخزون للتجّار المؤهّلين
لمزيد من المعلومات، يُرجى الاطّلاع على نظرة عامة حول "الإعلانات للمنتجات المتوفرة في المتجر" والبيانات المحلية المجانية.
المتطلبات الأساسية
يجب أن يتوفّر لديك ما يلي:
حساب على Merchant Center
ملف تجاري على Google إذا لم يكن لديك ملف تجاري، يمكنك إنشاء ملف تجاري. يُرجى الاطّلاع على مقالة الاشتراك في "الملف التجاري على 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 صالح يُستخدَم للمراجعة المحدّدة قد يؤدي معرّف 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` لتوفير مزيد من المعلومات عن صفحة منتجك.
إذا اخترت أنواع واجهة محلّ محلية يستضيفها تاجر وحدّدت حقل معرّف 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)
استلام الطلب
بالإضافة إلى التوفّر في المتجر، يمكنك أيضًا تحسين منتجاتك المتوفّرة في المتجر باستخدام ميزة "استلام الطلب"، التي لا تكون مؤهّلة إلا لأنواع واجهة محلّ محلية يستضيفها تاجر.
عند وضع علامة "استلام الطلب" على منتج، يعني ذلك أنّه يمكن للعميل شراؤه على الإنترنت واستلامه من المتجر. من خلال ضبط حقل 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.
بالنسبة إلى جميع التجّار في هذه البلدان الثلاثة، لا تفعّل الخدمة ميزات "البيانات المحلية المجانية" و"إعلانات للمنتجات داخل المتجر (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.
في ما يلي عيّنة تعليمات برمجية:
جافا
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.
قبل استدعاء هذا RPC، عليك تنفيذ ما يلي:
- تحميل بيانات المنتج وبيانات المستودع
- إثبات صحة جهة اتصال للتحقق من معلومات المخزون
- بالنسبة إلى التجّار في ألمانيا والنمسا وسويسرا، إكمال مراجعة صفحة
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);
}
}
عرض حالة إعداد قناة تسويق شاملة
للاطّلاع على حالة مراجعة عمليات الإعداد في "إعلانات للمنتجات داخل المتجر (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فارغًا في الطلب. - إذا اخترت أنواع واجهة محلّ محلية يستضيفها تاجر، قدِّم معرّف URI واحدًا على الأقل في
InStockأوPickup.
تعديل إعداد قناة تسويق شاملة
تتطلب طريقة التعديل لهذا المورد القواعد الإضافية التالية:
- لا يمكنك تعديل رمز المنطقة.
- لا يمكنك إجراء تعديلات أثناء تشغيل ميزة "إعلانات للمنتجات داخل المتجر (LIA)" و"البيانات المحلية المجانية" أو بعد الموافقة عليها.
- عند التغيير من أنواع واجهة محلّ محلية يستضيفها تاجر إلى
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 إذا أردت تقديم الطلب قبل ذلك الوقت.
مزيد من المعلومات
لمزيد من التفاصيل، يُرجى الاطّلاع على مركز مساعدة "الإعلانات للمنتجات المتوفرة في المتجر" والبيانات المحلية المجانية.